fixed script for freebsd

This commit is contained in:
afeiszli 2021-11-16 20:56:22 -05:00
parent cf5739796a
commit 39cd054521
2 changed files with 53 additions and 14 deletions

View file

@ -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

View file

@ -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<<EOL
server:
host:
apiport: "8081"
grpcport: "50051"
masterkey: "secretkey"
allowedorigin: "*"
restbackend: true
agentbackend: true
dnsmode: "on"
EOL
cat >/etc/systemd/system/netmaker.service<<EOL
[Unit]
Description=Netmaker Server
After=network.target
[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/etc/netmaker
ExecStart=/etc/netmaker/netmaker
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl start netmaker.service