feat: support multi-service management (#251)
Some checks are pending
EasyTier Core / pre_job (push) Waiting to run
EasyTier Core / build (linux-aarch64, ubuntu-latest, aarch64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-arm, ubuntu-latest, arm-unknown-linux-musleabi) (push) Blocked by required conditions
EasyTier Core / build (linux-armhf, ubuntu-latest, arm-unknown-linux-musleabihf) (push) Blocked by required conditions
EasyTier Core / build (linux-armv7, ubuntu-latest, armv7-unknown-linux-musleabi) (push) Blocked by required conditions
EasyTier Core / build (linux-armv7hf, ubuntu-latest, armv7-unknown-linux-musleabihf) (push) Blocked by required conditions
EasyTier Core / build (linux-mips, ubuntu-latest, mips-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-mipsel, ubuntu-latest, mipsel-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-x86_64, ubuntu-latest, x86_64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Blocked by required conditions
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Blocked by required conditions
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Blocked by required conditions
EasyTier Core / core-result (push) Blocked by required conditions
EasyTier GUI / pre_job (push) Waiting to run
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-latest, aarch64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-latest, x86_64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Blocked by required conditions
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Blocked by required conditions
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Blocked by required conditions
EasyTier GUI / gui-result (push) Blocked by required conditions
EasyTier Mobile / pre_job (push) Waiting to run
EasyTier Mobile / build-mobile (android, ubuntu-latest, android) (push) Blocked by required conditions
EasyTier Mobile / mobile-result (push) Blocked by required conditions
EasyTier Test / pre_job (push) Waiting to run
EasyTier Test / test (push) Blocked by required conditions

feat: support config (only config file now)
This commit is contained in:
Sunakier 2024-08-24 10:17:57 +08:00 committed by GitHub
parent e4df03053e
commit 31b26222d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,20 +118,6 @@ elif [ "$ARCH" == "UNKNOWN" ]; then
elif ! command -v systemctl >/dev/null 2>&1; then elif ! command -v systemctl >/dev/null 2>&1; then
echo -e "\r\n${RED_COLOR}Opus${RES}, your Linux do not support systemctl\r\nnTry ${GREEN_COLOR}install by band${RES}\r\n" echo -e "\r\n${RED_COLOR}Opus${RES}, your Linux do not support systemctl\r\nnTry ${GREEN_COLOR}install by band${RES}\r\n"
exit 1 exit 1
else
if command -v netstat >/dev/null 2>&1; then
check_port=$(netstat -lnp | grep 11010 | awk '{print $7}' | awk -F/ '{print $1}')
else
echo -e "${GREEN_COLOR}Check port ...${RES}"
if command -v yum >/dev/null 2>&1; then
yum install net-tools -y >/dev/null 2>&1
check_port=$(netstat -lnp | grep 11010 | awk '{print $7}' | awk -F/ '{print $1}')
else
apt-get update >/dev/null 2>&1
apt-get install net-tools -y >/dev/null 2>&1
check_port=$(netstat -lnp | grep 11010 | awk '{print $7}' | awk -F/ '{print $1}')
fi
fi
fi fi
CHECK() { CHECK() {
@ -178,8 +164,10 @@ INSTALL() {
# Unzip resource # Unzip resource
echo -e "\r\n${GREEN_COLOR}Unzip resource ...${RES}" echo -e "\r\n${GREEN_COLOR}Unzip resource ...${RES}"
unzip -o /tmp/easytier_tmp_install.zip -d $INSTALL_PATH/ unzip -o /tmp/easytier_tmp_install.zip -d $INSTALL_PATH/
mkdir $INSTALL_PATH/config
mv $INSTALL_PATH/easytier-linux-${ARCH}/* $INSTALL_PATH/ mv $INSTALL_PATH/easytier-linux-${ARCH}/* $INSTALL_PATH/
rm -rf $INSTALL_PATH/easytier-linux-${ARCH}/ rm -rf $INSTALL_PATH/easytier-linux-${ARCH}/
chmod +x $INSTALL_PATH/easytier-core $INSTALL_PATH/easytier-cli
if [ -f $INSTALL_PATH/easytier-core ] || [ -f $INSTALL_PATH/easytier-cli ]; then if [ -f $INSTALL_PATH/easytier-core ] || [ -f $INSTALL_PATH/easytier-cli ]; then
echo -e "${GREEN_COLOR} Download successfully! ${RES}" echo -e "${GREEN_COLOR} Download successfully! ${RES}"
else else
@ -194,8 +182,11 @@ INIT() {
exit 1 exit 1
fi fi
# Create default blank file config
touch $INSTALL_PATH/config/default.conf
# Create systemd # Create systemd
cat >/etc/systemd/system/easytier.service <<EOF cat >/etc/systemd/system/easytier@.service <<EOF
[Unit] [Unit]
Description=EasyTier Service Description=EasyTier Service
Wants=network.target Wants=network.target
@ -204,23 +195,24 @@ After=network.target network.service
[Service] [Service]
Type=simple Type=simple
WorkingDirectory=$INSTALL_PATH WorkingDirectory=$INSTALL_PATH
ExecStart=/bin/bash $INSTALL_PATH/run.sh ExecStart=$INSTALL_PATH/easytier-core -c $INSTALL_PATH/config/%i.conf
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
# Create run script # # Create run script
cat >$INSTALL_PATH/run.sh <<EOF # cat >$INSTALL_PATH/run.sh <<EOF
$INSTALL_PATH/easytier-core # $INSTALL_PATH/easytier-core
EOF # EOF
# Startup # Startup
systemctl daemon-reload systemctl daemon-reload
systemctl enable easytier >/dev/null 2>&1 systemctl enable easytier@default >/dev/null 2>&1
systemctl start easytier systemctl start easytier@default
# For issues from the previous version # For issues from the previous version
rm -rf /etc/systemd/system/easytier.service
rm -rf /usr/bin/easytier-core rm -rf /usr/bin/easytier-core
rm -rf /usr/bin/easytier-cli rm -rf /usr/bin/easytier-cli
@ -234,23 +226,25 @@ SUCCESS() {
echo " Install EasyTier successfully!" echo " Install EasyTier successfully!"
echo -e "\r\nDefault Port: ${GREEN_COLOR}11010(UDP+TCP)${RES}, Notice allowing in firewall!\r\n" echo -e "\r\nDefault Port: ${GREEN_COLOR}11010(UDP+TCP)${RES}, Notice allowing in firewall!\r\n"
echo -e "Staartup script path: ${GREEN_COLOR}$INSTALL_PATH/run.sh${RES}\n\r\n\rFor more advanced opinions, please modify the startup script" 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 "The management example of a single configuration file is as follows"
echo echo
echo -e "Status: ${GREEN_COLOR}systemctl status easytier${RES}" echo -e "Status: ${GREEN_COLOR}systemctl status easytier@default${RES}"
echo -e "Start: ${GREEN_COLOR}systemctl start easytier${RES}" echo -e "Start: ${GREEN_COLOR}systemctl start easytier@default${RES}"
echo -e "Restart: ${GREEN_COLOR}systemctl restart easytier${RES}" echo -e "Restart: ${GREEN_COLOR}systemctl restart easytier@default${RES}"
echo -e "Stop: ${GREEN_COLOR}systemctl stop easytier${RES}" echo -e "Stop: ${GREEN_COLOR}systemctl stop easytier@default${RES}"
echo echo
} }
UNINSTALL() { UNINSTALL() {
echo -e "\r\n${GREEN_COLOR}Uninstall EasyTier ...${RES}\r\n" echo -e "\r\n${GREEN_COLOR}Uninstall EasyTier ...${RES}\r\n"
echo -e "${GREEN_COLOR}Stop process ...${RES}" echo -e "${GREEN_COLOR}Stop process ...${RES}"
systemctl disable easytier >/dev/null 2>&1 systemctl disable "easytier@*" >/dev/null 2>&1
systemctl stop easytier >/dev/null 2>&1 systemctl stop "easytier@*" >/dev/null 2>&1
echo -e "${GREEN_COLOR}Delete files ...${RES}" echo -e "${GREEN_COLOR}Delete files ...${RES}"
rm -rf $INSTALL_PATH /etc/systemd/system/easytier.service /usr/bin/easytier-core /usr/bin/easytier-cli 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 systemctl daemon-reload
echo -e "\r\n${GREEN_COLOR}EasyTier was removed successfully! ${RES}\r\n" echo -e "\r\n${GREEN_COLOR}EasyTier was removed successfully! ${RES}\r\n"
} }
@ -262,7 +256,7 @@ UPDATE() {
else else
echo echo
echo -e "${GREEN_COLOR}Stopping EasyTier process${RES}\r\n" echo -e "${GREEN_COLOR}Stopping EasyTier process${RES}\r\n"
systemctl stop easytier systemctl stop "easytier@*"
# Backup # Backup
rm -rf /tmp/easytier_tmp_update rm -rf /tmp/easytier_tmp_update
mkdir -p /tmp/easytier_tmp_update mkdir -p /tmp/easytier_tmp_update
@ -275,11 +269,11 @@ UPDATE() {
echo "Rollback all ..." echo "Rollback all ..."
rm -rf $INSTALL_PATH/* rm -rf $INSTALL_PATH/*
mv /tmp/easytier_tmp_update/* $INSTALL_PATH/ mv /tmp/easytier_tmp_update/* $INSTALL_PATH/
systemctl start easytier systemctl start "easytier@*"
exit 1 exit 1
fi fi
echo -e "\r\n${GREEN_COLOR} Starting EasyTier process${RES}" echo -e "\r\n${GREEN_COLOR} Starting EasyTier process${RES}"
systemctl start easytier systemctl start "easytier@*"
echo -e "\r\n${GREEN_COLOR} EasyTier was the latest stable version! ${RES}\r\n" echo -e "\r\n${GREEN_COLOR} EasyTier was the latest stable version! ${RES}\r\n"
fi fi
} }