Merge pull request #731 from gravitl/develop

netclient-install script update
This commit is contained in:
Alex Feiszli 2022-02-10 10:45:06 -05:00 committed by GitHub
commit f3e4e1f673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 40 deletions

View file

@ -7,6 +7,8 @@
https://dashboard.NETMAKER_BASE_DOMAIN { https://dashboard.NETMAKER_BASE_DOMAIN {
# Apply basic security headers # Apply basic security headers
header { header {
# Enable cross origin access to *.NETMAKER_BASE_DOMAIN
Access-Control-Allow-Origin *.NETMAKER_BASE_DOMAIN
# Enable HTTP Strict Transport Security (HSTS) # Enable HTTP Strict Transport Security (HSTS)
Strict-Transport-Security "max-age=31536000;" Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks # Enable cross-site filter (XSS) and tell browser to block detected attacks

View file

@ -18,7 +18,7 @@ type Peer struct {
Interface string `json:"interface,omitempty"` Interface string `json:"interface,omitempty"`
PrivateIPv4 string `json:"private_ipv4,omitempty"` PrivateIPv4 string `json:"private_ipv4,omitempty"`
PrivateIPv6 string `json:"private_ipv6,omitempty"` PrivateIPv6 string `json:"private_ipv6,omitempty"`
PublicEndpoint string `json:"public_endoint,omitempty"` PublicEndpoint string `json:"public_endpoint,omitempty"`
} }
type Network struct { type Network struct {

View file

@ -25,6 +25,10 @@ elif [ -f /etc/fedora-release ]; then
dependencies="wireguard" dependencies="wireguard"
update_cmd='dnf update' update_cmd='dnf update'
install_cmd='dnf install -y' install_cmd='dnf install -y'
elif [ -f /etc/arch-releae ]; then
dependecies="wireguard-tools"
update_cmd='pacman -Sy'
install_cmd='pacman -S --noconfirm'
elif [ "${OS}" = "FreeBSD" ]; then elif [ "${OS}" = "FreeBSD" ]; then
dependencies="wireguard" dependencies="wireguard"
update_cmd='pkg update' update_cmd='pkg update'
@ -118,9 +122,6 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
x86_64) x86_64)
dist=netclient dist=netclient
;; ;;
x86_32)
dist=netclient-32
;;
arm64) arm64)
dist=netclient-arm64 dist=netclient-arm64
;; ;;
@ -160,9 +161,6 @@ case $(uname | tr '[:upper:]' '[:lower:]') in
x86_64) x86_64)
dist=netclient-freebsd dist=netclient-freebsd
;; ;;
x86_32)
dist=netclient-freebsd-32
;;
arm64) arm64)
dist=netclient-freebsd-arm64 dist=netclient-freebsd-arm64
;; ;;
@ -194,13 +192,13 @@ if curl --output /dev/null --silent --head --fail "$url"; then
wget $curl_opts -O netclient $url wget $curl_opts -O netclient $url
else else
echo "Downloading $dist latest" echo "Downloading $dist latest"
wget $curl_opts -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist wget $curl_opts -O netclient https://github.com/gravitl/netmaker/releases/latest/download/$dist
fi fi
chmod +x netclient chmod +x netclient
EXTRA_ARGS="" EXTRA_ARGS=""
if [ "${OS}" = "FreeBSD" ] || [ "${OS}" = "OpenWRT" ]; then if [ "${OS}" = "OpenWRT" ]; then
EXTRA_ARGS="--daemon=off" EXTRA_ARGS="--daemon=off"
fi fi
@ -210,34 +208,9 @@ else
./netclient join -t $KEY --name $NAME $EXTRA_ARGS ./netclient join -t $KEY --name $NAME $EXTRA_ARGS
fi fi
if [ "${OS}" = "FreeBSD" ]; then
mv ./netclient /etc/netclient/netclient
cat << 'END_OF_FILE' > ./netclient.service.tmp
#!/bin/sh
# PROVIDE: netclient if [ "${OS}" = "OpenWRT" ]; then
# REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEM mv ./netclient /sbin/netclient
# BEFORE:
# KEYWORD: shutdown
. /etc/rc.subr
name="netclient"
rcvar=netclient_enable
pidfile="/var/run/${name}.pid"
command="/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"
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
elif [ "${OS}" = "OpenWRT" ]; then
mv ./netclient /etc/netclient/netclient
cat << 'END_OF_FILE' > ./netclient.service.tmp cat << 'END_OF_FILE' > ./netclient.service.tmp
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
@ -251,18 +224,18 @@ start() {
if [ ! -f "${LOG_FILE}" ];then if [ ! -f "${LOG_FILE}" ];then
touch "${LOG_FILE}" touch "${LOG_FILE}"
fi fi
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') local PID=$(ps|grep "netclient daemon"|grep -v grep|awk '{print $1}')
if [ "${PID}" ];then if [ "${PID}" ];then
echo "service is running" echo "service is running"
return return
fi fi
bash -c "while [ 1 ]; do /etc/netclient/netclient checkin -n all >> ${LOG_FILE} 2>&1;sleep 15;\ bash -c "do /sbin/netclient daemon >> ${LOG_FILE} 2>&1;\
if [ $(ls -l ${LOG_FILE}|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &" if [ $(ls -l ${LOG_FILE}|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &"
echo "start" echo "start"
} }
stop() { stop() {
pids=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') pids=$(ps|grep "netclient daemon"|grep -v grep|awk '{print $1}')
for i in "${pids[@]}" for i in "${pids[@]}"
do do
if [ "${i}" ];then if [ "${i}" ];then
@ -273,7 +246,7 @@ stop() {
} }
status() { status() {
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') local PID=$(ps|grep "netclient daemon"|grep -v grep|awk '{print $1}')
if [ "${PID}" ];then if [ "${PID}" ];then
echo -e "netclient[${PID}] is running \n" echo -e "netclient[${PID}] is running \n"
else else