summaryrefslogtreecommitdiffstats
path: root/util/bbsctl.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /util/bbsctl.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/bbsctl.c')
-rw-r--r--util/bbsctl.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/util/bbsctl.c b/util/bbsctl.c
new file mode 100644
index 00000000..bf66df35
--- /dev/null
+++ b/util/bbsctl.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+void usage(void)
+{
+ printf("usage: bbsctl [start|stop|restart]\n");
+ exit(0);
+}
+
+void startbbs(void)
+{
+ if( setuid(0) < 0 ){
+ perror("setuid(0)");
+ exit(1);
+ }
+ puts("starting mbbsd: 23"); system("/home/bbs/bin/mbbsd 23");
+ puts("starting mbbsd:3000"); system("/home/bbs/bin/mbbsd 3000");
+ puts("starting mbbsd:3001"); system("/home/bbs/bin/mbbsd 3001");
+ puts("starting mbbsd:3002"); system("/home/bbs/bin/mbbsd 3002");
+ puts("starting mbbsd:3003"); system("/home/bbs/bin/mbbsd 3003");
+ puts("starting mbbsd:3004"); system("/home/bbs/bin/mbbsd 3004");
+ puts("starting mbbsd:3005"); system("/home/bbs/bin/mbbsd 3005");
+ puts("starting mbbsd:3006"); system("/home/bbs/bin/mbbsd 3006");
+ puts("starting mbbsd:3007"); system("/home/bbs/bin/mbbsd 3007");
+ puts("starting mbbsd:3008"); system("/home/bbs/bin/mbbsd 3008");
+ puts("starting mbbsd:3009"); system("/home/bbs/bin/mbbsd 3009");
+ puts("starting mbbsd:3010"); system("/home/bbs/bin/mbbsd 3010");
+}
+
+void stopbbs(void)
+{
+ char buf[1024];
+ int pid;
+ FILE *fp = popen("/bin/ps -ax | /usr/bin/grep mbbsd | "
+ "/usr/bin/grep listen", "r");
+ while( fgets(buf, sizeof(buf), fp) != NULL ){
+ sscanf(buf, "%d", &pid);
+ printf("stopping %d\n", pid);
+ kill(pid, 1);
+ }
+}
+
+void restartbbs(void)
+{
+ stopbbs();
+ startbbs();
+}
+
+int main(int argc, char **argv)
+{
+ if( argc == 1 )
+ usage();
+ if( strcmp(argv[1], "start") == 0 )
+ startbbs();
+ else if( strcmp(argv[1], "stop") == 0 )
+ stopbbs();
+ else if( strcmp(argv[1], "restart") == 0 )
+ restartbbs();
+ return 0;
+}