Spaces:
Running
Running
Upload launch.sh
Browse files
launch.sh
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 reverse_proxy=$(jq -r .reverse_proxy data.json)
|
12 |
+
export proxy_password=$(jq -r .proxy_password data.json)
|
13 |
+
export api_key_makersuite=$(jq -r .api_key_makersuite data.json)
|
14 |
+
export github_secret=$(jq -r .github_secret data.json)
|
15 |
+
export github_project=$(jq -r .github_project data.json)
|
16 |
+
fi
|
17 |
+
|
18 |
+
echo
|
19 |
+
echo "fetch = ${fetch}"
|
20 |
+
echo "reverse_proxy = $reverse_proxy"
|
21 |
+
echo "proxy_password = $proxy_password"
|
22 |
+
echo "api_key_makersuite = $api_key_makersuite"
|
23 |
+
echo "github_secret = $github_secret"
|
24 |
+
echo "github_project = $github_project"
|
25 |
+
echo "USERNAME = ${USERNAME}"
|
26 |
+
echo "PASSWORD = ${PASSWORD}"
|
27 |
+
echo
|
28 |
+
echo
|
29 |
+
|
30 |
+
IFS="," RESOURCES="糖水galV1.9.0g,糖水otomeV1.9.0g,修改版 V1.4.8_KaruKaru,修改版 V1.4.9_KaruKaru" && \
|
31 |
+
\
|
32 |
+
echo "*** Edit default $RESOURCES in OpenAI Settings ***" && \
|
33 |
+
for R in $RESOURCES; do sed -i "s#\"reverse_proxy\": \"\",#\"reverse_proxy\": \"${reverse_proxy}\",#g" "data/default-user/OpenAI Settings/$R.json"; done || true && \
|
34 |
+
for R in $RESOURCES; do sed -i "s#\"proxy_password\": \"\",#\"proxy_password\": \"${proxy_password}\",#g" "data/default-user/OpenAI Settings/$R.json"; done || true
|
35 |
+
sed -i "s/\"api_key_makersuite\": \"\"/\"api_key_makersuite\": \"${api_key_makersuite}\"/g" secrets.json
|
36 |
+
sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh
|
37 |
+
sed -i "s#\[github_project\]#${github_project}#g" launch.sh
|
38 |
+
|
39 |
+
sed -i "s#\[proxies_url\]#${reverse_proxy}#g" config/settings.json
|
40 |
+
sed -i "s/\[proxies_passwd\]/${proxy_password}/g" config/settings.json
|
41 |
+
}
|
42 |
+
|
43 |
+
function init() {
|
44 |
+
mkdir ${BASE}/history
|
45 |
+
cd ${BASE}/history
|
46 |
+
|
47 |
+
git config --global user.email "[email protected]"
|
48 |
+
git config --global user.name "complete-Mmx"
|
49 |
+
git config --global init.defaultBranch main
|
50 |
+
git init
|
51 |
+
git remote add origin https://[github_secret]@github.com/[github_project].git
|
52 |
+
git add .
|
53 |
+
echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
54 |
+
git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
55 |
+
git pull origin main
|
56 |
+
|
57 |
+
cd ${BASE}
|
58 |
+
|
59 |
+
DIR="${BASE}/history"
|
60 |
+
if [ "$(ls -A $DIR | grep -v .git)" ]; then
|
61 |
+
echo "Has history..."
|
62 |
+
else
|
63 |
+
echo "Empty history..."
|
64 |
+
cp -r data/* history/
|
65 |
+
cp -r secrets.json history/secrets.json
|
66 |
+
fi
|
67 |
+
|
68 |
+
rm -rf data
|
69 |
+
ln -s history data
|
70 |
+
|
71 |
+
cp -r config/settings.json history/default-user/settings.json
|
72 |
+
ln -s history/default-user/settings.json data/default-user/settings.json
|
73 |
+
|
74 |
+
rm -r secrets.json
|
75 |
+
ln -s history/default-user/secrets.json secrets.json
|
76 |
+
|
77 |
+
rm -r config.yaml
|
78 |
+
cp config/config.yaml history/config.yaml
|
79 |
+
ln -s history/config.yaml config.yaml
|
80 |
+
sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml
|
81 |
+
sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml
|
82 |
+
cat config.yaml
|
83 |
+
echo "Init history."
|
84 |
+
chmod -R 777 history
|
85 |
+
|
86 |
+
nohup ./git-batch --commit 10s --name git-batch --email [email protected] --push 1m -p history > access.log 2>1 &
|
87 |
+
}
|
88 |
+
|
89 |
+
function release() {
|
90 |
+
rm -rf history
|
91 |
+
}
|
92 |
+
|
93 |
+
function update() {
|
94 |
+
cd ${BASE}/history
|
95 |
+
git pull origin main
|
96 |
+
git add .
|
97 |
+
echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
98 |
+
git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
99 |
+
git push origin main
|
100 |
+
}
|
101 |
+
|
102 |
+
case $1 in
|
103 |
+
env)
|
104 |
+
env
|
105 |
+
;;
|
106 |
+
init)
|
107 |
+
init
|
108 |
+
;;
|
109 |
+
release)
|
110 |
+
release
|
111 |
+
;;
|
112 |
+
update)
|
113 |
+
update
|
114 |
+
;;
|
115 |
+
esac
|