Skip to content

Commit

Permalink
chore: add usage for script
Browse files Browse the repository at this point in the history
  • Loading branch information
alomerry committed Feb 1, 2024
1 parent 50c4589 commit 0f08db3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
11 changes: 11 additions & 0 deletions vm/scripts/app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 11 additions & 0 deletions vm/scripts/app/install/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 11 additions & 0 deletions vm/scripts/app/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
33 changes: 31 additions & 2 deletions vm/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -59,4 +88,4 @@ main() {
main $@

# run.sh setup server
# run.sh install frp_client
# run.sh install frp_client

0 comments on commit 0f08db3

Please sign in to comment.