Browse Source

removed installation of freebsd daemon (done by netclient)
updated openwrt daemon to installl in /sbin and update command to be run
removed x86_32
add support for arch

Matthew R. Kasun 3 years ago
parent
commit
09f8114cc0
1 changed files with 7 additions and 38 deletions
  1. 7 38
      scripts/netclient-install.sh

+ 7 - 38
scripts/netclient-install.sh

@@ -118,9 +118,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 +157,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
 			;;
 			;;
@@ -200,7 +194,7 @@ 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 +204,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
-# REQUIRE: LOGIN DAEMON NETWORKING SERVERS FILESYSTEM
-# 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
+if [ "${OS}" = "OpenWRT" ]; then
+	mv ./netclient /sbin/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 +220,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 +242,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