summarylogtreecommitdiffstats
path: root/0000a-advman.systemd.patch
blob: 1adb7d424705d8ecbde0ceab564e1c8bdb638b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
diff -pNaru10 a/script/advman b/script/advman
--- a/script/advman	2023-01-04 01:50:39.287161354 -0500
+++ b/script/advman	2023-01-04 01:51:33.067094078 -0500
@@ -1,147 +1,35 @@
 #!/bin/bash
 
 set -u
 if [ "${EUID}" -ne 0 ]; then
   echo "Must be root"
   exit 1
 fi
 
-COMMAND=0
-SCRIPT=$0
-INSTALLPATH=/usr/share/advtty
-DEAMON=advttyd
-SERVICE=vcomd
-DRIVER=advvcom
-SSLPROXY=advsslvcom
-CONFIGFILE=/etc/advttyd.conf
-DEAMONFILE=$INSTALLPATH/$DEAMON
-#DKMSFILE=/lib/modules/`uname -r`/updates/dkms/$DRIVER.ko
-#KERNEL=`uname -r|cut -c1-3`
-if false # [ $KERNEL = "2.4" ]
-then
-DRIVERFILE=$INSTALLPATH/$DRIVER.o
-else
-DRIVERFILE=$DRIVER
-fi
-
-RETURN=
 OBJECTIVE=
 
-hasdriver()
-{
-	COUNT=`lsmod | grep $DRIVER -c`
-	if [ $COUNT -gt 0 ]
-	then
-		echo "kernel moduel $DRIVER.ko detected..."
-		RETURN=1
-	else
-		echo "kernel moduel $DRIVER.ko not installed... try objective \"insert\" first"
-		RETURN=0
-	fi
-}
-
-insdriver()
-{
-	if false # [ $KERNEL = "2.4" ]
-	then
-	echo "inserting kernel moduel $DRIVER.o..."
-	modprobe $DRIVERFILE
-	elif false # [ -e $DKMSFILE ]
-	then
-	echo "inserting DKMS module $DRIVER.ko..."
-	modprobe $DKMSFILE
-	else
-	echo "inserting kernel moduel $DRIVER.ko..."
-	modprobe $DRIVERFILE
-	fi
-}
-
-rmdriver()
-{
-	if false # [ $KERNEL = "2.4" ]
-	then
-	echo "removing kernel moduel $DRIVER..."
-	rmmod $DRIVER
-	else
-	echo "removing kernel moduel $DRIVER.ko..."
-	rmmod $DRIVER.ko
-	fi
-}
-
-stopService()
-{
-	echo "stoping all local services..."
-	killall -s 9 $SERVICE
-}
-
-startDeamon()
-{
-	# for 2.4.x kernel, we should make node by myself
-	if false # [ $KERNEL = "2.4" ]
-	then
-		i=1
-		while [[ $i -le 256 ]]
-		do
-			if [ -z $(awk '$2=="vttyAP"{print $1}' /proc/devices) ]
-			then
-				mknod /dev/vttyAP$i c $(awk '$2=="vttyap/%d"{print $1}' /proc/devices) $i
-			else
-				mknod /dev/vttyAP$i c $(awk '$2=="vttyAP"{print $1}' /proc/devices) $i
-			fi
-			((i = i + 1))
-		done
-	fi
-	echo "invoking local deamon..."
-	install -m 700 -oroot -groot -d /tmp/advmon
-	#`$DEAMONFILE`
-	$DEAMONFILE
-
-}
-
-stopDeamon()
-{
-#	COUNT=`ps -A|grep $DEAMON -c`
-#	while [ $COUNT -gt 0 ]
-#	do
-#		PID=`ps -A|grep $DEAMON |sed -r s/^[[:space:]]*//g|sed  -r s/"[[:space:]]+.+[[:space:]]+[[:digit:]]+:[[:digit:]]+:[[:digit:]]+[[:space:]]+$DEAMON"/""/g | sed '/^[ \t]*$/d'|head -n 1`
-#
-#		echo "killing $DEAMON $PID"
-#
-#		kill -9 $PID
-#		COUNT=`ps -A|grep $DEAMON -c`
-#	done
-	killall -s 9 $DEAMON
-	if false # [ $KERNEL = "2.4" ]
-	then
-        	rm -rf /dev/vttyAP*
-	fi
-
-	killall -s 9 $SSLPROXY
-}
-
-
 usage()
 {
 cat << EOF
 usage: $0 options
 
 This script lists helps you manage local advtty service.
 
 OPTIONS:
    -h      Show this message
    -o	   Execute objective:
    		start 	- start advtty local service
 		stop 	- stop advtty local service
 		restart	- restart advtty local service
-		insert	- insert $DRIVER.ko module
-		remove	- remove $DRIVER.ko module
+		insert	- insert module
+		remove	- remove module
 
 Example:
 	$0 -o start
 	$0 -o restart
 	$0 -o stop
 
 EOF
 }
 
 while getopts 'ho:' OPTION
@@ -156,61 +44,43 @@ do
              ;;
          ?)
 	     usage
              exit
              ;;
      esac
 done
 
 case $OBJECTIVE in
 	start)
-		hasdriver
-		if [ $RETURN -eq 1 ]
-		then
-			echo "starting service...."
-			startDeamon
-		else
-			echo "installing driver & start service..."
-			insdriver
-			startDeamon
-		fi
+		systemctl start 'advtty-vcom.service'
 		# systemd-notify --ready
 		exit 0
 	;;
 	restart)
-		hasdriver
-		if [ $RETURN -eq 1 ]
-		then
-			echo "starting service...."
-			startDeamon
-		else
-			echo "can not start service..."
-			insdriver
-			startDeamon
-		fi
+		systemctl reload 'advtty-vcom.service'
 		# systemd-notify --ready
 		exit 0
 
 	;;
 	stop)
-		echo stop
-		stopService
-		stopDeamon
+		systemctl stop 'advtty-vcom.service'
 		# systemd-notify --ready
 		exit 0
 	;;
 	insert)
-		insdriver
+		modprobe 'advvcom'
 		# systemd-notify --ready
 		exit 0
 	;;
 	remove)
-		stopService
-		stopDeamon
-		rmdriver
+		systemctl stop 'advtty-vcom.service'
 		# systemd-notify --ready
 		exit 0
 	;;
+	*)
+		usage
+		exit 1
+	;;
 esac
 usage