|
#!/bin/sh |
|
|
|
function env() { |
|
if [[ ! -z "${fetch}" ]]; then |
|
echo '远程获取参数...' |
|
curl -s "$fetch" -o data.json |
|
export github_secret=$(jq -r .github_secret data.json) |
|
export github_project=$(jq -r .github_project data.json) |
|
fi |
|
|
|
echo |
|
echo "fetch = ${fetch}" |
|
echo "github_secret = $github_secret" |
|
echo "github_project = $github_project" |
|
echo |
|
echo |
|
|
|
sed -i "s/\[github_secret\]/${github_secret}/g" /launch.sh |
|
sed -i "s#\[github_project\]#${github_project}#g" /launch.sh |
|
} |
|
|
|
function init() { |
|
|
|
|
|
cd /data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
git clone https://${github_secret}@github.com/${github_project}.git . |
|
git config --add safe.directory /data |
|
git add . |
|
echo "'update data $(date "+%Y-%m-%d %H:%M:%S")'" |
|
git commit -m "'update data $(date "+%Y-%m-%d %H:%M:%S")'" |
|
git pull origin main |
|
|
|
cd / |
|
chmod -R 777 data |
|
nohup ./git-batch --commit 10s --name git-batch --email [email protected] --push 1m -p data > access.log 2>1 & |
|
} |
|
|
|
case $1 in |
|
env) |
|
env |
|
;; |
|
init) |
|
init |
|
;; |
|
start) |
|
init |
|
/one-api |
|
;; |
|
esac |
|
|