-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
51 lines (48 loc) · 1.81 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# usage: sudo bash install.sh
# install rsync
if [ $# -eq 0 ]; then
if [[ -e /etc/os-release ]]; then
source /etc/os-release
if [[ $ID == "debian" || $ID == "ubuntu" ]]; then
apt-get install -y rsync
elif [[ $ID == "centos" || $ID == "rhel" ]]; then
yum install -y rsync
elif [[ $ID == "alpine" ]]; then
apk add -y rsync
else
echo "Unsupported Linux distribution"
exit 1
fi
else
echo "Unsupported Linux distribution"
exit 1
fi
# install scow-sync
local_path=$(pwd)
dir_path=$local_path/scow_sync
chmod +x $dir_path/scow-sync-start
chmod +x $dir_path/scow-sync-query
chmod +x $dir_path/scow-sync-terminate
ln -s $dir_path/scow-sync-start /usr/bin/scow-sync-start # install scow-sync globally by add soft link in /usr/local/bin
ln -s $dir_path/scow-sync-query /usr/bin/scow-sync-query
ln -s $dir_path/scow-sync-terminate /usr/bin/scow-sync-terminate
ln -s $dir_path/scow-sync /usr/bin/scow-sync
chmod +x /usr/bin/scow-sync-start
chmod +x /usr/bin/scow-sync-query
chmod +x /usr/bin/scow-sync-terminate
chmod +x /usr/bin/scow-sync
fi
# config the shebang
if [ "$1" = "update" ]; then
# 读取SHEBANG_PATH变量
SHEBANG_PATH=$(python3 -c "from scow_sync import config; print(config.SHEBANG_PATH)")
# 更新scow-sync脚本的shebang行
sed -i "1s|.*|#!$SHEBANG_PATH|" ./scow_sync/scow-sync
# 更新scow-sync-start脚本的shebang行
sed -i "1s|.*|#!$SHEBANG_PATH|" ./scow_sync/scow-sync-start
# 更新scow-sync-query脚本的shebang行
sed -i "1s|.*|#!$SHEBANG_PATH|" ./scow_sync/scow-sync-query
# 更新scow-sync-terminate脚本的shebang行
sed -i "1s|.*|#!$SHEBANG_PATH|" ./scow_sync/scow-sync-terminate
fi