mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
adding freebsd script
This commit is contained in:
parent
27c9bfe223
commit
9ba0b16a99
2 changed files with 116 additions and 15 deletions
|
@ -7,6 +7,8 @@ fi
|
|||
|
||||
echo "checking dependencies..."
|
||||
|
||||
OS=$(uname)
|
||||
|
||||
if [ -f /etc/debian_version ]; then
|
||||
install_cmd='apt-get install -y'
|
||||
elif [ -f /etc/alpine-release ]; then
|
||||
|
@ -15,6 +17,8 @@ elif [ -f /etc/centos-release ]; then
|
|||
install_cmd='yum install -y'
|
||||
elif [ -f /etc/fedora-release ]; then
|
||||
install_cmd='dnf install -y'
|
||||
elif [ OS == "FreeBSD" ]; then
|
||||
install_cmd='pkg install -y'
|
||||
else
|
||||
install_cmd=''
|
||||
fi
|
||||
|
@ -27,6 +31,25 @@ dependencies="wireguard"
|
|||
set -- $dependencies
|
||||
while [ -n "$1" ]; do
|
||||
echo $1
|
||||
if [ OS == "FreeBSD" ]; then
|
||||
is_installed=$(pkg check -d $1 | grep '100%')
|
||||
if [ "${is_installed}" = '100%' ]; then
|
||||
echo " " $1 is installed
|
||||
else
|
||||
echo " " $1 is not installed. Attempting install.
|
||||
${install_cmd} $1
|
||||
sleep 5
|
||||
is_installed=$(pkg check -d $1 | grep '100%')
|
||||
if [ "${is_installed}" = '100%' ]; then
|
||||
echo " " $1 is installed
|
||||
elif [ -x "$(command -v $1)" ]; then
|
||||
echo " " $1 is installed
|
||||
else
|
||||
echo " " FAILED TO INSTALL $1
|
||||
echo " " This may break functionality.
|
||||
fi
|
||||
fi
|
||||
else
|
||||
is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed")
|
||||
if [ "${is_installed}" = "install ok installed" ]; then
|
||||
echo " " $1 is installed
|
||||
|
@ -44,6 +67,7 @@ while [ -n "$1" ]; do
|
|||
echo " " This may break functionality.
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
|
@ -93,6 +117,36 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
|
|||
darwin)
|
||||
dist=netclient-darwin
|
||||
;;
|
||||
freebsd*)
|
||||
if [ -z "$CPU_ARCH" ]; then
|
||||
CPU_ARCH=$(uname -m)
|
||||
fi
|
||||
case $CPU_ARCH in
|
||||
amd64)
|
||||
dist=netclient-freebsd
|
||||
;;
|
||||
x86_64)
|
||||
dist=netclient-freebsd
|
||||
;;
|
||||
x86_32)
|
||||
dist=netclient-freebsd-32
|
||||
;;
|
||||
arm64)
|
||||
dist=netclient-freebsd-arm64
|
||||
;;
|
||||
aarch64)
|
||||
dist=netclient-freebsd-arm64
|
||||
;;
|
||||
armv7l)
|
||||
dist=netclient-freebsd-armv7
|
||||
;;
|
||||
arm*)
|
||||
dist=netclient-freebsd-$CPU_ARCH
|
||||
;;
|
||||
*)
|
||||
fatal "$CPU_ARCH : cpu architecture not supported"
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Binary = $dist"
|
||||
|
@ -107,10 +161,40 @@ else
|
|||
fi
|
||||
chmod +x netclient
|
||||
|
||||
EXTRA_ARGS = ""
|
||||
if [ OS == "FreeBSD" ]; then
|
||||
EXTRA_ARGS = "--daemon=off"
|
||||
fi
|
||||
|
||||
if [ -z "${NAME}" ]; then
|
||||
sudo ./netclient join -t $KEY
|
||||
sudo ./netclient join -t $KEY EXTRA_ARGS
|
||||
else
|
||||
sudo ./netclient join -t $KEY --name $NAME
|
||||
sudo ./netclient join -t $KEY --name $NAME EXTRA_ARGS
|
||||
fi
|
||||
|
||||
rm -f netclient
|
||||
|
||||
if [ OS == "FreeBSD" ]; then
|
||||
tee /usr/local/etc/rc.d/netclient <<'EOF' >/dev/null
|
||||
#!/bin/sh
|
||||
|
||||
# PROVIDE: netclient
|
||||
# REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEM
|
||||
# BEFORE:
|
||||
# KEYWORD: shutdown
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="netclient"
|
||||
rcvar=netclient_enable
|
||||
pidfile="/var/run/${name}.pid"
|
||||
command="/usr/sbin/daemon"
|
||||
command_args="-c -f -P ${pidfile} -R 10 -t "Netclient" -u root -o /etc/netclient/netclient.log /etc/netclient/netclient checkin -n all"
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
||||
|
||||
EOF
|
||||
/usr/local/etc/rc.d/netclient enable
|
||||
/usr/local/etc/rc.d/netclient start
|
||||
fi
|
17
scripts/netclient-rc-freebsd
Normal file
17
scripts/netclient-rc-freebsd
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# PROVIDE: netclient
|
||||
# REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEM
|
||||
# BEFORE:
|
||||
# KEYWORD: shutdown
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="netclient"
|
||||
rcvar=netclient_enable
|
||||
pidfile="/var/run/${name}.pid"
|
||||
command="/usr/sbin/daemon"
|
||||
command_args="-c -f -P ${pidfile} -R 10 -t "Netclient" -u root -o /etc/netclient/netclient.log /etc/netclient/netclient checkin -n all"
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
Loading…
Reference in a new issue