Skip to content

Commit

Permalink
Rebased.
Browse files Browse the repository at this point in the history
Show detected architecture.

Fix systemctl warning.

Fix systemctl warning again.

Force stop service before upgrade.

Support hot update.

Add shebang.

Fix arch strings.

Fix bug when determining whether to copy configuration file templetes.

Add quick deploy command.

Change URL in usage to main repository.
  • Loading branch information
hathlife committed Feb 6, 2020
1 parent 216e046 commit 51279de
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# deploy
Deploy scripts for frp.
Deploy scripts for frp.
Usage:
> bash < ( curl -s -L https://github.com/gofrp/deploy/raw/master/frp_deploy.sh )
41 changes: 36 additions & 5 deletions frp_install.sh → frp_deploy.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
#!/bin/bash

#Set flags for hot update.

frps_FLAG=`ps -ef |grep -w frps|grep -v grep|wc -l`
frpc_FLAG=`ps -ef |grep -w frpc|grep -v grep|wc -l`

#Force stop services before upgrade.

systemctl stop frps

systemctl stop frpc

#Detect the arch.

case $(uname -m) in
"x86_64")
ARCH="amd64"
;;
"i*86")
ARCH="i386"
ARCH="386"
;;
"armv8")
"arm64")
ARCH="arm64"
;;
"arm")
"armhf")
ARCH="arm"
;;
"mips64")
Expand All @@ -23,13 +36,15 @@ case $(uname -m) in
ARCH="mips"
;;
*)
echo "Unsupport architecture." && exit
echo "Unsupport architecture." && exit 0
esac
echo "Detected ${ARCH} architecture."
#Get latest release tag
RELEASETAG=$(git ls-remote --tags https://github.com/fatedier/frp | sort -t '/' -k 2 -V | sed -e '/\^/d')
export FRP_VERSION=${RELEASETAG:0-6}
echo "The latest frp release is ${FRP_VERSION}"
mkdir -p /etc/frp

rm -rf /tmp/frp_${FRP_VERSION}_linux_${ARCH}*
cd /tmp
echo "Downloading tar package from Github......"
Expand All @@ -42,12 +57,28 @@ cd /tmp
cp ./frp_${FRP_VERSION}_linux_${ARCH}/frpc /usr/bin && chmod +x /usr/bin/frpc
setcap cap_net_bind_service=ep /usr/bin/frps #Give frps binary access to well-known ports(smbd,NetBIOS,etc).
echo "Installing configuration files......"
test -e /etc/frp/frpc.ini && echo "Configuration files exist." || echo "Configuration files do not exist. Copy templetes." && cp ./frp_${FRP_VERSION}_linux_${ARCH}/frp*.ini /etc/frp
test -e /etc/frp/frpc.ini && echo "Configuration files exist. Do not copy templetes." || (echo "Configuration files do not exist. Copy templetes." && cp ./frp_${FRP_VERSION}_linux_${ARCH}/frp*.ini /etc/frp)
echo "Configuration file is installed to /etc/frp ."

#Fix systemctl warning.
cp ./frp_${FRP_VERSION}_linux_${ARCH}/systemd/* /lib/systemd/system
systemctl daemon-reload

echo "Install complete."
echo "See https://github.com/fatedier/frp/blob/master/README.md for configuration."
echo "Use \"systemctl start frps\" or \"systemctl start frpc\" to start frpc\frps service."

#Auto restart services.

if [ $frps_FLAG ]
then
systemctl start frps
elif [ $frpc_FLAG ]
then
systemctl start frpc
fi

#systemctl enable frps
#systemctl enable frpc

rm -rf /tmp/frp_${FRP_VERSION}_linux_${ARCH}*

0 comments on commit 51279de

Please sign in to comment.