Spaces:
Paused
Paused
Upload launch.sh
Browse files
launch.sh
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
if [[ -z "${USERNAME}" ]]; then
|
| 16 |
+
USERNAME="root"
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
if [[ -z "${PASSWORD}" ]]; then
|
| 20 |
+
PASSWORD="123456"
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
echo
|
| 24 |
+
echo "fetch = ${fetch}"
|
| 25 |
+
echo "github_secret = $github_secret"
|
| 26 |
+
echo "github_project = $github_project"
|
| 27 |
+
echo "USERNAME = ${USERNAME}"
|
| 28 |
+
echo "PASSWORD = ${PASSWORD}"
|
| 29 |
+
echo
|
| 30 |
+
echo
|
| 31 |
+
|
| 32 |
+
sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh
|
| 33 |
+
sed -i "s#\[github_project\]#${github_project}#g" launch.sh
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
function init() {
|
| 37 |
+
mkdir ${BASE}/history
|
| 38 |
+
cd ${BASE}/history
|
| 39 |
+
|
| 40 |
+
git config --global user.email "huggingface@hf.com"
|
| 41 |
+
git config --global user.name "complete-Mmx"
|
| 42 |
+
git config --global init.defaultBranch main
|
| 43 |
+
git init
|
| 44 |
+
git remote add origin https://[github_secret]@github.com/[github_project].git
|
| 45 |
+
git add .
|
| 46 |
+
echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
| 47 |
+
git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
| 48 |
+
git pull origin main
|
| 49 |
+
|
| 50 |
+
cd ${BASE}
|
| 51 |
+
|
| 52 |
+
DIR="${BASE}/history"
|
| 53 |
+
if [ "$(ls -A $DIR | grep -v .git)" ]; then
|
| 54 |
+
echo "Has history..."
|
| 55 |
+
else
|
| 56 |
+
echo "Empty history..."
|
| 57 |
+
cp -r data/* history/
|
| 58 |
+
cp -r secrets.json history/secrets.json
|
| 59 |
+
fi
|
| 60 |
+
|
| 61 |
+
rm -rf data
|
| 62 |
+
ln -s history data
|
| 63 |
+
|
| 64 |
+
rm -r config.yaml
|
| 65 |
+
cp config/config.yaml history/config.yaml
|
| 66 |
+
ln -s history/config.yaml config.yaml
|
| 67 |
+
sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml
|
| 68 |
+
sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml
|
| 69 |
+
sed -i "s/whitelistMode: true/whitelistMode: false/" ${BASE}/config.yaml
|
| 70 |
+
sed -i "s/basicAuthMode: false/basicAuthMode: true/" ${BASE}/config.yaml
|
| 71 |
+
cat config.yaml
|
| 72 |
+
echo "Init history."
|
| 73 |
+
chmod -R 777 history
|
| 74 |
+
|
| 75 |
+
nohup ./git-batch --commit 10s --name git-batch --email git-batch@github.com --push 1m -p history > access.log 2>1 &
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function release() {
|
| 79 |
+
rm -rf history
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function update() {
|
| 83 |
+
cd ${BASE}/history
|
| 84 |
+
git pull origin main
|
| 85 |
+
git add .
|
| 86 |
+
echo "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
| 87 |
+
git commit -m "'update history$(date "+%Y-%m-%d %H:%M:%S")'"
|
| 88 |
+
git push origin main
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
case $1 in
|
| 92 |
+
env)
|
| 93 |
+
env
|
| 94 |
+
;;
|
| 95 |
+
init)
|
| 96 |
+
init
|
| 97 |
+
;;
|
| 98 |
+
release)
|
| 99 |
+
release
|
| 100 |
+
;;
|
| 101 |
+
update)
|
| 102 |
+
update
|
| 103 |
+
;;
|
| 104 |
+
esac
|