mirror of
https://github.com/EasyTier/EasyTier.git
synced 2025-09-26 20:51:17 +08:00
install script support openrc (#868)
Some checks failed
EasyTier Core / pre_job (push) Has been cancelled
EasyTier Core / build_web (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-arm64, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-i686, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier Core / magisk_build (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-arm64, aarch64-pc-windows-msvc, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-i686, i686-pc-windows-msvc, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled
Some checks failed
EasyTier Core / pre_job (push) Has been cancelled
EasyTier Core / build_web (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-arm64, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-i686, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier Core / magisk_build (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-arm64, aarch64-pc-windows-msvc, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-i686, i686-pc-windows-msvc, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled
This commit is contained in:
@@ -157,21 +157,30 @@ if [ "$(id -u)" != "0" ]; then
|
||||
echo -e "\r\n${RED_COLOR}This script requires run as Root !${RES}\r\n" 1>&2
|
||||
exit 1
|
||||
elif [ "$ARCH" == "UNKNOWN" ]; then
|
||||
echo -e "\r\n${RED_COLOR}Opus${RES}, this script do not support your platfrom\r\nTry ${GREEN_COLOR}install by band${RES}\r\n"
|
||||
exit 1
|
||||
elif ! command -v systemctl >/dev/null 2>&1; then
|
||||
echo -e "\r\n${RED_COLOR}Opus${RES}, your Linux do not support systemctl\r\nTry ${GREEN_COLOR}install by band${RES}\r\n"
|
||||
echo -e "\r\n${RED_COLOR}Opus${RES}, this script do not support your platform\r\nTry ${GREEN_COLOR}install by hand${RES}\r\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect init system
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
INIT_SYSTEM="systemd"
|
||||
elif command -v rc-update >/dev/null 2>&1; then
|
||||
INIT_SYSTEM="openrc"
|
||||
else
|
||||
echo -e "\r\n${RED_COLOR}Error: Unsupported init system (neither systemd nor OpenRC found)${RES}\r\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
CHECK() {
|
||||
if ! $SKIP_FOLDER_VERIFY; then
|
||||
if [ -f "$INSTALL_PATH/easytier-core" ]; then
|
||||
echo "There is EasyTier in $INSTALL_PATH. Please choose other path or use \"update\""
|
||||
echo -e "Or use Try ${GREEN_COLOR}--skip-folder-verify${RES} to skip"
|
||||
exit 0
|
||||
fi
|
||||
if [ -f "$INSTALL_PATH/easytier-core" ]; then
|
||||
echo "There is EasyTier in $INSTALL_PATH. Please choose other path or use \"update\""
|
||||
echo -e "Or use Try ${GREEN_COLOR}--skip-folder-verify${RES} to skip"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d "$INSTALL_PATH/" ]; then
|
||||
mkdir -p $INSTALL_PATH
|
||||
else
|
||||
@@ -194,7 +203,7 @@ INSTALL() {
|
||||
LATEST_VERSION=$(echo -e "$LATEST_VERSION" | tr -d '[:space:]')
|
||||
|
||||
if [ -z "$LATEST_VERSION" ]; then
|
||||
echo -e "\r\n${RED_COLOR}Opus${RES}, failure to get latest version. Check your internel\r\nOr try ${GREEN_COLOR}install by band${RES}\r\n"
|
||||
echo -e "\r\n${RED_COLOR}Opus${RES}, failure to get latest version. Check your internet\r\nOr try ${GREEN_COLOR}install by hand${RES}\r\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -265,8 +274,32 @@ disable_udp_hole_punching = false
|
||||
|
||||
EOF
|
||||
|
||||
# Create init script
|
||||
if [ "$INIT_SYSTEM" = "openrc" ]; then
|
||||
cat >/etc/init.d/easytier <<EOF
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name="EasyTier"
|
||||
description="EasyTier Service"
|
||||
command="$INSTALL_PATH/easytier-core"
|
||||
command_args="-c $INSTALL_PATH/config/default.conf"
|
||||
command_user="nobody:nobody"
|
||||
command_background=true
|
||||
|
||||
pidfile="/run/\${RC_SVCNAME}.pid"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
||||
|
||||
|
||||
EOF
|
||||
chmod +x /etc/init.d/easytier
|
||||
fi
|
||||
|
||||
# Create systemd
|
||||
cat >/etc/systemd/system/easytier@.service <<EOF
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
cat >/etc/systemd/system/easytier@.service <<EOF
|
||||
[Unit]
|
||||
Description=EasyTier Service
|
||||
Wants=network.target
|
||||
@@ -283,6 +316,7 @@ RestartSec=1s
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
fi
|
||||
|
||||
# # Create run script
|
||||
# cat >$INSTALL_PATH/run.sh <<EOF
|
||||
@@ -290,9 +324,14 @@ EOF
|
||||
# EOF
|
||||
|
||||
# Startup
|
||||
systemctl daemon-reload
|
||||
systemctl enable easytier@default >/dev/null 2>&1
|
||||
systemctl start easytier@default
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable easytier@default >/dev/null 2>&1
|
||||
systemctl start easytier@default
|
||||
else
|
||||
rc-update add easytier default
|
||||
rc-service easytier start
|
||||
fi
|
||||
|
||||
# For issues from the previous version
|
||||
rm -rf /etc/systemd/system/easytier.service
|
||||
@@ -311,25 +350,41 @@ SUCCESS() {
|
||||
echo -e "Default Network Name: ${GREEN_COLOR}default${RES}, Please change it to your own network name!\r\n"
|
||||
|
||||
echo -e "Now EasyTier supports multiple config files. You can create config files in the ${GREEN_COLOR}${INSTALL_PATH}/config/${RES} folder"
|
||||
echo -e "For more information, please check the documents in offical site"
|
||||
echo -e "For more information, please check the documents in official site"
|
||||
echo -e "The management example of a single configuration file is as follows"
|
||||
|
||||
echo
|
||||
echo -e "Status: ${GREEN_COLOR}systemctl status easytier@default${RES}"
|
||||
echo -e "Start: ${GREEN_COLOR}systemctl start easytier@default${RES}"
|
||||
echo -e "Restart: ${GREEN_COLOR}systemctl restart easytier@default${RES}"
|
||||
echo -e "Stop: ${GREEN_COLOR}systemctl stop easytier@default${RES}"
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
echo -e "Status: ${GREEN_COLOR}systemctl status easytier@default${RES}"
|
||||
echo -e "Start: ${GREEN_COLOR}systemctl start easytier@default${RES}"
|
||||
echo -e "Restart: ${GREEN_COLOR}systemctl restart easytier@default${RES}"
|
||||
echo -e "Stop: ${GREEN_COLOR}systemctl stop easytier@default${RES}"
|
||||
else
|
||||
echo -e "Status: ${GREEN_COLOR}rc-service easytier status${RES}"
|
||||
echo -e "Start: ${GREEN_COLOR}rc-service easytier start${RES}"
|
||||
echo -e "Restart: ${GREEN_COLOR}rc-service easytier restart${RES}"
|
||||
echo -e "Stop: ${GREEN_COLOR}rc-service easytier stop${RES}"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
UNINSTALL() {
|
||||
echo -e "\r\n${GREEN_COLOR}Uninstall EasyTier ...${RES}\r\n"
|
||||
echo -e "${GREEN_COLOR}Stop process ...${RES}"
|
||||
systemctl disable "easytier@*" >/dev/null 2>&1
|
||||
systemctl stop "easytier@*" >/dev/null 2>&1
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
systemctl disable "easytier@*" >/dev/null 2>&1
|
||||
systemctl stop "easytier@*" >/dev/null 2>&1
|
||||
else
|
||||
rc-update del easytier
|
||||
rc-service easytier stop
|
||||
fi
|
||||
echo -e "${GREEN_COLOR}Delete files ...${RES}"
|
||||
rm -rf $INSTALL_PATH /etc/systemd/system/easytier.service /usr/bin/easytier-core /usr/bin/easytier-cli /etc/systemd/system/easytier@.service /usr/sbin/easytier-cli /usr/sbin/easytier-cli
|
||||
systemctl daemon-reload
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
rm -rf $INSTALL_PATH /etc/systemd/system/easytier.service /usr/bin/easytier-core /usr/bin/easytier-cli /etc/systemd/system/easytier@.service /usr/sbin/easytier-core /usr/sbin/easytier-cli
|
||||
systemctl daemon-reload
|
||||
else
|
||||
rm -rf $INSTALL_PATH /etc/init.d/easytier /usr/bin/easytier-core /usr/bin/easytier-cli /usr/sbin/easytier-core /usr/sbin/easytier-cli
|
||||
fi
|
||||
echo -e "\r\n${GREEN_COLOR}EasyTier was removed successfully! ${RES}\r\n"
|
||||
}
|
||||
|
||||
@@ -340,24 +395,37 @@ UPDATE() {
|
||||
else
|
||||
echo
|
||||
echo -e "${GREEN_COLOR}Stopping EasyTier process${RES}\r\n"
|
||||
systemctl stop "easytier@*"
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
systemctl stop "easytier@*"
|
||||
else
|
||||
rc-service easytier stop
|
||||
fi
|
||||
# Backup
|
||||
rm -rf /tmp/easytier_tmp_update
|
||||
mkdir -p /tmp/easytier_tmp_update
|
||||
cp -a $INSTALL_PATH/* /tmp/easytier_tmp_update/
|
||||
INSTALL
|
||||
if [ -f $INSTALL_PATH/easytier-core ]; then
|
||||
echo -e "${GREEN_COLOR} Vrify successfully ${RES}"
|
||||
echo -e "${GREEN_COLOR} Verify successfully ${RES}"
|
||||
else
|
||||
echo -e "${RED_COLOR} Download failed, unable to update${RES}"
|
||||
echo "Rollback all ..."
|
||||
rm -rf $INSTALL_PATH/*
|
||||
mv /tmp/easytier_tmp_update/* $INSTALL_PATH/
|
||||
systemctl start "easytier@*"
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
systemctl start "easytier@*"
|
||||
else
|
||||
rc-service easytier start
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\r\n${GREEN_COLOR} Starting EasyTier process${RES}"
|
||||
systemctl start "easytier@*"
|
||||
if [ "$INIT_SYSTEM" = "systemd" ]; then
|
||||
systemctl start "easytier@*"
|
||||
else
|
||||
rc-service easytier start
|
||||
fi
|
||||
echo -e "\r\n${GREEN_COLOR} EasyTier was updated successfully! ${RES}\r\n"
|
||||
echo -e "\r\n${GREEN_COLOR} EasyTier was the latest stable version! ${RES}\r\n"
|
||||
fi
|
||||
}
|
||||
@@ -393,4 +461,4 @@ else
|
||||
echo -e "\n\r${GREEN_COLOR} install, uninstall, update, help ${RES}"
|
||||
fi
|
||||
|
||||
rm -rf /tmp/easytier_tmp_*
|
||||
rm -rf /tmp/easytier_tmp_*
|
Reference in New Issue
Block a user