-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.sh
More file actions
executable file
·102 lines (88 loc) · 2.26 KB
/
launcher.sh
File metadata and controls
executable file
·102 lines (88 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
##############################################
################### GLOBAL ###################
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export ROOT_DIR="$DIR"
CERT_SYNC_BOT="$ROOT_DIR/misc/cert_sync_bot.sh"
GIT_RELEASE_UPDATER="$ROOT_DIR/misc/git_release_updater.sh"
STALKER="$ROOT_DIR/misc/stalker.sh"
SYSTEMD_BOT="$ROOT_DIR/misc/systemd_bot.sh"
UPDATE="$ROOT_DIR/misc/update.sh"
AUTO_AUTH="$ROOT_DIR/network/auto_auth.sh"
SIMPLE_AUTH="$ROOT_DIR/network/simple_auth.sh"
SPEEDTEST="$ROOT_DIR/network/speedtest.sh"
exec 233<&0
export SURFACE_LAYER_STDIN_FD="233"
SCRIPT="$1"
SCRIPT_PID=""
##############################################
################ PROGRAMFUNC #################
# 创建后台进程手动关闭可以防止一些奇怪的情况
# 直接前台运行它也会创建子shell,有些时候就关不掉
function EXIT() {
kill "$SCRIPT_PID" >/dev/null 2>&1
wait "$SCRIPT_PID" >/dev/null 2>&1
exec 3<&-
exit "$@"
}
function USAGE() {
echo "请输入正确的参数!"
echo "用法: launcher.sh <脚本> <脚本参数>"
echo ""
echo "脚本列表:"
echo "—— misc"
echo " ——> cert_sync_bot"
echo " ——> git_release_updater"
echo " ——> stalker"
echo " ——> systemd_bot"
echo " ——> update"
echo "—— network"
echo " ——> auto_auth"
echo " ——> simple_auth"
echo " ——> speedtest"
echo ""
}
function MAIN() {
shift # 移除第一个参数(脚本名)
if [[ -z "$SCRIPT" ]]; then
USAGE
EXIT 1
fi
case "$SCRIPT" in
"cert_sync_bot")
$CERT_SYNC_BOT "$@" &
;;
"git_release_updater")
$GIT_RELEASE_UPDATER "$@" &
;;
"stalker")
$STALKER "$@" &
;;
"systemd_bot")
$SYSTEMD_BOT "$@" &
;;
"update")
$UPDATE "$@" &
;;
"auto_auth")
$AUTO_AUTH "$@" &
;;
"simple_auth")
$SIMPLE_AUTH "$@" &
;;
"speedtest")
$SPEEDTEST "$@" &
;;
*)
echo "未知的脚本名称"
USAGE
EXIT 1
;;
esac
SCRIPT_PID="$!"
wait "$SCRIPT_PID"
EXIT 0
}
trap EXIT SIGINT SIGTERM
MAIN "$@"