From 39cd0545214d07e1f113799ad79ef308470a5f2e Mon Sep 17 00:00:00 2001 From: afeiszli Date: Tue, 16 Nov 2021 20:56:22 -0500 Subject: [PATCH] fixed script for freebsd --- scripts/netclient-install.sh | 31 +++++++++++++++++-------------- scripts/netmaker-server.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 scripts/netmaker-server.sh diff --git a/scripts/netclient-install.sh b/scripts/netclient-install.sh index e9504ece..c342fa49 100755 --- a/scripts/netclient-install.sh +++ b/scripts/netclient-install.sh @@ -32,15 +32,15 @@ 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 + is_installed=$(pkg check -d $1 | grep "Checking" | grep "done") + if [ "$is_installed" != "" ]; 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 + is_installed=$(pkg check -d $1 | grep "Checking" | grep "done") + if [ "$is_installed" != "" ]; then echo " " $1 is installed elif [ -x "$(command -v $1)" ]; then echo " " $1 is installed @@ -159,30 +159,29 @@ else echo "Downloading $dist latest" wget -nv -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist fi + chmod +x netclient EXTRA_ARGS="" if [ "${OS}" = "FreeBSD" ]; then - EXTRA_ARGS = "--daemon=off" + EXTRA_ARGS="--daemon=off" fi if [ -z "${NAME}" ]; then -sudo ./netclient join -t $KEY $EXTRA_ARGS + ./netclient join -t $KEY $EXTRA_ARGS else -sudo ./netclient join -t $KEY --name $NAME $EXTRA_ARGS + ./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 + mv ./netclient /etc/netclient/netclient + cat << 'END_OF_FILE' > ./netclient.service.tmp #!/bin/sh # PROVIDE: netclient # REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEM # BEFORE: # KEYWORD: shutdown - . /etc/rc.subr name="netclient" @@ -194,7 +193,11 @@ command_args="-c -f -P ${pidfile} -R 10 -t "Netclient" -u root -o /etc/netclient load_rc_config $name run_rc_command "$1" -EOF - /usr/local/etc/rc.d/netclient enable - /usr/local/etc/rc.d/netclient start +END_OF_FILE + sudo mv ./netclient.service.tmp /usr/local/etc/rc.d/netclient + sudo chmod +x /usr/local/etc/rc.d/netclient + sudo /usr/local/etc/rc.d/netclient enable + sudo /usr/local/etc/rc.d/netclient start +else + rm -f netclient fi diff --git a/scripts/netmaker-server.sh b/scripts/netmaker-server.sh new file mode 100644 index 00000000..dbaefce4 --- /dev/null +++ b/scripts/netmaker-server.sh @@ -0,0 +1,36 @@ +#!/bin/sh +set -e + +mkdir -p /etc/netmaker/config/environments +wget -O /etc/netmaker/netmaker https://github.com/gravitl/netmaker/releases/download/latest/netmaker +chmod +x /etc/netmaker/netmaker + +cat >/etc/netmaker/config/environments/dev.yaml</etc/systemd/system/netmaker.service<