Skip to content

Commit 61a7383

Browse files
committed
feat: new install script and config path
1 parent 9d30cee commit 61a7383

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

conf/settings.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,31 @@ func Get() *Config {
5959

6060
func InitConfig() {
6161
var (
62-
err error
62+
err error
63+
useEnvFile bool
6364
)
6465

65-
if err = godotenv.Load(); err != nil {
66-
logrus.WithError(err).Infof("Error loading .env file, will use runtime env")
66+
envFiles := []string{
67+
".env",
68+
"/etc/frpp/.env",
69+
}
70+
71+
for i, envFile := range envFiles {
72+
if err = godotenv.Load(envFile); err == nil {
73+
logrus.Infof("load env file success: %s", envFile)
74+
useEnvFile = true
75+
break
76+
}
77+
if i == len(envFiles)-1 {
78+
logrus.Errorf("cannot load env file: %s, error: %v", envFile, err)
79+
useEnvFile = false
80+
break
81+
}
82+
logrus.Infof("cannot load env file: %s, error: %v, try next", envFile, err)
83+
}
84+
85+
if !useEnvFile {
86+
logrus.Info("use runtime env variables")
6787
}
6888

6989
cfg := Config{}

install.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33
OS=$(uname -s)
44
ARCH=$(uname -m)
55

6+
if [ "$(curl -s https://ipinfo.io/country)" = "CN" ]; then
7+
prefix="https://mirror.ghproxy.com/"
8+
echo "监测到您的IP在中国,使用镜像下载"
9+
else
10+
prefix=""
11+
fi
12+
613
case "$OS" in
714
Linux)
815
case "$ARCH" in
916
x86_64)
10-
wget -O frp-panel https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-linux-amd64
17+
wget -O frp-panel "${prefix}https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-linux-amd64"
1118
;;
1219
aarch64)
13-
wget -O frp-panel https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-linux-arm64
20+
wget -O frp-panel "${prefix}https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-linux-arm64"
1421
;;
1522
esac
1623
;;
1724
Darwin)
1825
case "$ARCH" in
1926
x86_64)
20-
wget -O frp-panel https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-darwin-amd64
27+
wget -O frp-panel "${prefix}https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-darwin-amd64"
2128
;;
2229
arm64)
23-
wget -O frp-panel https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-darwin-arm64
30+
wget -O frp-panel "${prefix}https://github.com/VaalaCat/frp-panel/releases/latest/download/frp-panel-darwin-arm64"
2431
;;
2532
esac
2633
;;
@@ -35,8 +42,7 @@ chmod +x frp-panel
3542
sudo mv frp-panel /usr/local/bin/frp-panel
3643

3744
get_start_params() {
38-
echo "请输入启动参数:"
39-
read -r params
45+
read -p "请输入启动参数:" params
4046
echo "$params"
4147
}
4248

@@ -66,4 +72,6 @@ sudo systemctl daemon-reload
6672

6773
sudo systemctl start frpp
6874

69-
sudo systemctl enable frpp
75+
sudo systemctl restart frpp
76+
77+
sudo systemctl enable frpp

0 commit comments

Comments
 (0)