From 0f08db320e5085d9b1bfb2fff4d65a31ffaa9e4e Mon Sep 17 00:00:00 2001 From: Alomerry Wu Date: Thu, 1 Feb 2024 22:19:44 +0800 Subject: [PATCH] chore: add usage for script --- vm/scripts/app/build.sh | 11 +++++++++++ vm/scripts/app/install/index.sh | 11 +++++++++++ vm/scripts/app/setup.sh | 11 +++++++++++ vm/scripts/run.sh | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/vm/scripts/app/build.sh b/vm/scripts/app/build.sh index 418ad2e0..babf0e8c 100644 --- a/vm/scripts/app/build.sh +++ b/vm/scripts/app/build.sh @@ -38,3 +38,14 @@ build() { eval "build_$module" done } + +build_usage() { + command=(blog docs) + desc=(博客 文档) + echo "usage: alomerry.sh build 本地构建" + echo -e "\nOptions:" + for idx in 0 1; do + printf " - %-20s %-20s\n" ${command[$idx]} ${desc[$idx]} + done + exit 1 +} diff --git a/vm/scripts/app/install/index.sh b/vm/scripts/app/install/index.sh index 27469a11..565298b4 100644 --- a/vm/scripts/app/install/index.sh +++ b/vm/scripts/app/install/index.sh @@ -37,3 +37,14 @@ install() { eval "install_$module" done } + +install_usage() { + command=(acme frp_server frp_client java nginx nvm rust v2ray_server v2ray_client) + desc=(acme frp_server frp_client java nginx nvm rust v2ray_server v2ray_client) + echo "usage: alomerry.sh install 安装软件" + echo -e "\nOptions:" + for idx in 0 1 2 3 4 5 6 7 8; do + printf " - %-20s %-20s\n" ${command[$idx]} ${desc[$idx]} + done + exit 1 +} \ No newline at end of file diff --git a/vm/scripts/app/setup.sh b/vm/scripts/app/setup.sh index 6884af4c..aee5ea92 100644 --- a/vm/scripts/app/setup.sh +++ b/vm/scripts/app/setup.sh @@ -36,4 +36,15 @@ setup() { for module in $@ ; do eval "setup_$module" done +} + +setup_usage() { + command=(server local ssh ssl_issue ssl_renew) + desc=(设置服务器 设置家庭 将本地ssh-key添加到服务器 初始化https证书 续签https证书) + echo "usage: alomerry.sh setup 设置系统" + echo -e "\nOptions:" + for idx in 0 1 2 3 4; do + printf " - %-20s %-20s\n" ${command[$idx]} ${desc[$idx]} + done + exit 1 } \ No newline at end of file diff --git a/vm/scripts/run.sh b/vm/scripts/run.sh index ccea47d8..d341da0d 100755 --- a/vm/scripts/run.sh +++ b/vm/scripts/run.sh @@ -37,8 +37,37 @@ boot() { source /tmp/setup.sh } +usage() { + case "$1" in + setup) + setup_usage ${@:1} + ;; + build) + build_usage ${@:1} + ;; + install) + install_usage ${@:1} + ;; + *) + echo "usage: alomerry.sh" + echo -e "\nOptions:" + echo " - setup" + echo " - build" + echo " - install" + exit 1 + ;; + esac +} + main() { - boot + args=$# + # boot + # TODO 单独先处理一遍参数 + if [ ${!args} == -h ]; then + usage ${@:1:`expr ${args} - 1`} + return + fi + # ATTENTION: 安装 ansible 以使用 ansible-vault 解密 case "$1" in setup) # server local ssh ssl ssl_{issue,renew} @@ -59,4 +88,4 @@ main() { main $@ # run.sh setup server -# run.sh install frp_client \ No newline at end of file +# run.sh install frp_client