CoolFace
Apppublic

HuggingMahiro/Tavern

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
launch.sh116 linesDownload Raw Back to root
1#!/bin/sh2 3BASE=/home/node/app4USERNAME=$(printenv username)5PASSWORD=$(printenv password)6 7function env() {8  if [[ ! -z "${fetch}" ]]; then9    echo '远程获取参数...'10    curl -s "$fetch" -o data.json11    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  fi17 18  echo19  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  echo28  echo29 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 || true35  sed -i "s/\"api_key_makersuite\": \"\"/\"api_key_makersuite\": \"${api_key_makersuite}\"/g" secrets.json36  sed -i "s/\[github_secret\]/${github_secret}/g" launch.sh37  sed -i "s#\[github_project\]#${github_project}#g" launch.sh38 39  sed -i "s#\[proxies_url\]#${reverse_proxy}#g" config/settings.json40  sed -i "s/\[proxies_passwd\]/${proxy_password}/g" config/settings.json41}42 43function init() {44  mkdir ${BASE}/history45  cd ${BASE}/history46 47  git config --global user.email "huggingface@hf.com"48  git config --global user.name "complete-Mmx"49  git config --global init.defaultBranch main50  git init51  git remote add origin https://[github_secret]@github.com/[github_project].git52  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 main56 57  cd ${BASE}58 59  DIR="${BASE}/history"60  if [ "$(ls -A $DIR | grep -v .git)" ]; then61    echo "Has history..."62  else63    echo "Empty history..."64    cp -r data/* history/65    cp -r secrets.json history/secrets.json66  fi67 68  rm -rf data69  ln -s history data70 71  cp -r config/settings.json history/default-user/settings.json72  ln -s history/default-user/settings.json data/default-user/settings.json73 74  rm -r secrets.json75  ln -s history/default-user/secrets.json secrets.json76 77  rm -r config.yaml78  cp config/config.yaml history/config.yaml79  ln -s history/config.yaml config.yaml80  sed -i "s/username: .*/username: \"${USERNAME}\"/" ${BASE}/config.yaml81  sed -i "s/password: .*/password: \"${PASSWORD}\"/" ${BASE}/config.yaml82  cat config.yaml83  echo "Init history."84  chmod -R 777 history85 86  nohup ./git-batch --commit 10s --name git-batch --email git-batch@github.com --push 1m -p history > access.log 2>1 &87}88 89function release() {90  rm -rf history91}92 93function update() {94  cd ${BASE}/history95  git pull origin main96  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 main100}101 102case $1 in103  env)104    env105  ;;106  init)107    init108  ;;109  release)110    release111  ;;112  update)113    update114  ;;115esac116