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 524427b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 10 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
}
58 changes: 48 additions & 10 deletions vm/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,75 @@ JAVA_VERSION=${JAVA_VERSION:-"8"}

boot() {
# https://raw.githubusercontent.com/alomerry/mix/master/vm/scripts/app/tools.sh
wget $SCRIPTS_PATH/app/tools.sh -O /tmp/tools.sh
wget $SCRIPTS_PATH/app/setup.sh -O /tmp/setup.sh
wget $SCRIPTS_PATH/app/build.sh -O /tmp/build.sh
wget $SCRIPTS_PATH/app/install/index.sh -O /tmp/install.sh
if [ ! -f /tmp/tools.sh ]; then
wget $SCRIPTS_PATH/app/tools.sh -O /tmp/tools.sh
fi
if [ ! -f /tmp/setup.sh ]; then
wget $SCRIPTS_PATH/app/setup.sh -O /tmp/setup.sh
fi
if [ ! -f /tmp/build.sh ]; then
wget $SCRIPTS_PATH/app/build.sh -O /tmp/build.sh
fi
if [ ! -f /tmp/install.sh ]; then
wget $SCRIPTS_PATH/app/install/index.sh -O /tmp/install.sh
fi
# https://blog.csdn.net/Renard_H/article/details/121458554
source /tmp/tools.sh
source /tmp/install.sh
source /tmp/build.sh
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() {
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}
setup)
setup ${@:2}
;;
build) # blog,docs
build)
build ${@:2}
;;
install) # acme rust nginx java frp_{server,client} v2ray_{server,client} nvm
install)
install ${@:2}
;;
update)
rm -rf /tmp/tools.sh /tmp/setup.sh /tmp/build.sh /tmp/install.sh
boot
;;
*)
echo "Done!"
;;
esac
}

main $@

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

0 comments on commit 524427b

Please sign in to comment.