This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
install_linux.sh
executable file
·83 lines (68 loc) · 1.64 KB
/
install_linux.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
###
# @Author: EagleXiang
# @LastEditors: EagleXiang
# @Email: eagle.xiang@outlook.com
# @Github: https://github.com/eaglexiang
# @Date: 2019-08-24 11:16:00
# @LastEditTime: 2019-08-28 21:33:55
###
# $1 为文件名
copy_config() {
if [ -f "$root/etc/eagle-tunnel.d/$1" ]; then
echo "find $1, new file will be named $1_new"
cp "./config/$1" "$root/etc/eagle-tunnel.d/$1_new"
else
cp "./config/$1" "$root/etc/eagle-tunnel.d/$1"
fi
}
# $1 为文件夹名
copy_config_dir() {
\cp -rf "./config/$1" "$root/etc/eagle-tunnel.d/"
}
# main
if [ ! -f "./et.go.linux" ];then
echo "no et.go.linux"
exit 1
fi
if [ "$1" == "test" ] && [ "$2" == "clean" ]
then
rm -rf "$(pwd)/test"
exit 0
elif [ "$1" == "test" ]
then
root="$(pwd)/test"
fi
# user check
if [ X"$root" == "X" ];then # root not specific
if [ $UID -ne 0 ]; then
echo "this script requires superuser privileges."
exit 1
fi
fi
# copy files
# lib
echo "lib installing..."
mkdir -p "$root/usr/eagle-tunnel"
\cp -f ./et.go.linux "$root/usr/eagle-tunnel/"
# etc
echo "etc installing..."
mkdir -p "$root/etc/eagle-tunnel.d"
copy_config client.conf
copy_config server.conf
copy_config users.list
copy_config_dir hosts
copy_config_dir proxylists
copy_config_dir directlists
# bin
echo "bin installing..."
mkdir -p "$root/bin"
ln -sf "$root/usr/lib/eagle-tunnel/et.go.linux" "$root/bin/et"
# systemd
echo "systemd units installing..."
mkdir -p "$root/usr/lib/systemd/system"
\cp -f ./config/nix/systemd/* "$root/usr/lib/systemd/system"
if [ X"$root" == "X" ];then # root not specific
systemctl daemon-reload
fi
echo "done"