Spaces:
Paused
Paused
Update auto.sh
Browse files
auto.sh
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
|
3 |
BASE=/home/node/app
|
4 |
|
|
|
|
|
|
|
5 |
function env() {
|
6 |
if [[ ! -z "${fetch}" ]]; then
|
7 |
echo '远程获取参数...'
|
@@ -34,9 +37,11 @@ function env() {
|
|
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
|
@@ -48,6 +53,12 @@ function init() {
|
|
48 |
git pull origin main
|
49 |
|
50 |
cd ${BASE}
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
DIR="${BASE}/history"
|
52 |
if [ "$(ls -A $DIR | grep -v .git)" ]; then
|
53 |
echo "Has history..."
|
@@ -57,15 +68,17 @@ function init() {
|
|
57 |
cp -r secrets.json history/secrets.json
|
58 |
fi
|
59 |
|
|
|
60 |
rm -rf config
|
61 |
ln -s history config
|
62 |
rm -r secrets.json
|
63 |
ln -s history/secrets.json secrets.json
|
|
|
64 |
echo "Init history."
|
65 |
chmod -R 777 history
|
66 |
|
67 |
echo "'init history$(date "+%Y-%m-%d %H:%M:%S")'" > history/hello.txt
|
68 |
-
nohup ./git-batch -v 4 --commit-interval 10s --name git-batch --email git-batch@github.com --push-interval 1m -p history > access.log 2
|
69 |
}
|
70 |
|
71 |
function release() {
|
|
|
2 |
|
3 |
BASE=/home/node/app
|
4 |
|
5 |
+
USERNAME=$(printenv username)
|
6 |
+
PASSWORD=$(printenv password)
|
7 |
+
|
8 |
function env() {
|
9 |
if [[ ! -z "${fetch}" ]]; then
|
10 |
echo '远程获取参数...'
|
|
|
37 |
}
|
38 |
|
39 |
function init() {
|
40 |
+
# 创建历史存储目录
|
41 |
mkdir ${BASE}/history
|
42 |
cd ${BASE}/history
|
43 |
|
44 |
+
# 设置 Git 用户信息,稍后注意要替换为实际信息
|
45 |
git config --global user.email "huggingface@hf.com"
|
46 |
git config --global user.name "complete-Mmx"
|
47 |
git config --global init.defaultBranch main
|
|
|
53 |
git pull origin main
|
54 |
|
55 |
cd ${BASE}
|
56 |
+
|
57 |
+
# 在移动原配置文件到历史目录 *之前* 更新 config.yaml 文件
|
58 |
+
sed -i "s/username: .*/username: ${USERNAME}/" ${BASE}/config/config.yaml
|
59 |
+
sed -i "s/password: .*/password: ${PASSWORD}/" ${BASE}/config/config.yaml
|
60 |
+
|
61 |
+
# 检查历史目录是否为空,然后复制配置文件
|
62 |
DIR="${BASE}/history"
|
63 |
if [ "$(ls -A $DIR | grep -v .git)" ]; then
|
64 |
echo "Has history..."
|
|
|
68 |
cp -r secrets.json history/secrets.json
|
69 |
fi
|
70 |
|
71 |
+
# 移除旧的配置文件和链接,创建新的指向历史目录的链接
|
72 |
rm -rf config
|
73 |
ln -s history config
|
74 |
rm -r secrets.json
|
75 |
ln -s history/secrets.json secrets.json
|
76 |
+
|
77 |
echo "Init history."
|
78 |
chmod -R 777 history
|
79 |
|
80 |
echo "'init history$(date "+%Y-%m-%d %H:%M:%S")'" > history/hello.txt
|
81 |
+
nohup ./git-batch -v 4 --commit-interval 10s --name git-batch --email git-batch@github.com --push-interval 1m -p history > access.log 2>&1 &
|
82 |
}
|
83 |
|
84 |
function release() {
|