wIK5Ez2o commited on
Commit
7ce8cfd
·
verified ·
1 Parent(s): 7bb0d75

Upload launch.sh

Browse files
Files changed (1) hide show
  1. launch.sh +96 -0
launch.sh ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ BASE=/home/node/app
4
+ USERNAME=$(printenv username)
5
+ PASSWORD=$(printenv password)
6
+
7
+ function env() {
8
+ if [[ ! -z "${fetch}" ]]; then
9
+ echo '远程获取参数...'
10
+ curl -s "$fetch" -o data.json
11
+ export github_secret=$(jq -r .github_secret data.json)
12
+ export github_project=$(jq -r .github_project data.json)
13
+ fi
14
+
15
+ echo
16
+ echo "fetch = ${fetch}"
17
+ echo "github_secret = $github_secret"
18
+ echo "github_project = $github_project"
19
+ echo "USERNAME = ${USERNAME}"
20
+ echo "PASSWORD = ${PASSWORD}"
21
+ echo
22
+ echo
23
+
24
+ sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh
25
+ sed -i "s#\[github_project\]#${github_project}#g" launch.sh
26
+ }
27
+
28
+ function init() {
29
+ mkdir ${BASE}/history
30
+ cd ${BASE}/history
31
+
32
+ git config --global user.email "[email protected]"
33
+ git config --global user.name "complete-Mmx"
34
+ git config --global init.defaultBranch main
35
+ git init
36
+ git remote add origin https://[github_secret]@github.com/[github_project].git
37
+ git add .
38
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
39
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
40
+ git pull origin main
41
+
42
+ cd ${BASE}
43
+
44
+ DIR="${BASE}/history"
45
+ if [ "$(ls -A $DIR | grep -v .git)" ]; then
46
+ echo "Has history..."
47
+ else
48
+ echo "Empty history..."
49
+ cp -r data/* history/
50
+ cp -r secrets.json history/secrets.json
51
+ fi
52
+
53
+ rm -rf data
54
+ ln -s history data
55
+
56
+ rm -r config.yaml
57
+ cp config/config.yaml history/config.yaml
58
+ ln -s history/config.yaml config.yaml
59
+ sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml
60
+ sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml
61
+ sed -i "s/whitelistMode: true/whitelistMode: false/" ${BASE}/config.yaml
62
+ sed -i "s/basicAuthMode: false/basicAuthMode: true/" ${BASE}/config.yaml
63
+ cat config.yaml
64
+ echo "Init history."
65
+ chmod -R 777 history
66
+
67
+ nohup ./git-batch --commit 10s --name git-batch --email [email protected] --push 1m -p history > access.log 2>1 &
68
+ }
69
+
70
+ function release() {
71
+ rm -rf history
72
+ }
73
+
74
+ function update() {
75
+ cd ${BASE}/history
76
+ git pull origin main
77
+ git add .
78
+ echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
79
+ git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
80
+ git push origin main
81
+ }
82
+
83
+ case $1 in
84
+ env)
85
+ env
86
+ ;;
87
+ init)
88
+ init
89
+ ;;
90
+ release)
91
+ release
92
+ ;;
93
+ update)
94
+ update
95
+ ;;
96
+ esac