]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/misc-progs/sambactrl.c
Control Skripe korrigiert
[people/pmueller/ipfire-2.x.git] / src / misc-progs / sambactrl.c
index a8fe5dd52ce150eda1929696b3c8e7faf0d04d75..f81b295cc27553d7f249a7b5c54b6a252cd42345 100644 (file)
@@ -22,22 +22,19 @@ if (argc==1)
 fprintf (stderr, "Missing smbctrl command!\n");
 return 1;
 }
-
-if (strcmp(argv[1], "smbuserdisable")==0)
+else if (strcmp(argv[1], "smbuserdisable")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -d %s >/dev/null", argv[2]);
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbuserenable")==0)
+else if (strcmp(argv[1], "smbuserenable")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -e %s >/dev/null", argv[2]);
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbuserdelete")==0)
+else if (strcmp(argv[1], "smbuserdelete")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -x %s >/dev/null", argv[2]);
 safe_system(command);
@@ -45,32 +42,27 @@ snprintf(command, BUFFER_SIZE-1, "/usr/sbin/userdel %s >/dev/null", argv[2]);
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbsafeconf")==0)
+else if (strcmp(argv[1], "smbsafeconf")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
 return 0;
 }
-
-if (strcmp(argv[1], "smbsafeconfcups")==0)
+else if (strcmp(argv[1], "smbsafeconfcups")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf");
 return 0;
 }
-
-if (strcmp(argv[1], "smbsafeconfpdc")==0)
+else if (strcmp(argv[1], "smbsafeconfpdc")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
 return 0;
 }
-
-if (strcmp(argv[1], "smbsafeconfpdccups")==0)
+else if (strcmp(argv[1], "smbsafeconfpdccups")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf");
 return 0;
 }
-
-if (strcmp(argv[1], "smbglobalreset")==0)
+else if (strcmp(argv[1], "smbglobalreset")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/default.global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf");
 safe_system("/bin/cat /var/ipfire/samba/default.settings > /var/ipfire/samba/settings");
@@ -78,57 +70,47 @@ safe_system("/bin/cat /var/ipfire/samba/default.global > /var/ipfire/samba/globa
 safe_system("/bin/cat /var/ipfire/samba/default.pdc > /var/ipfire/samba/pdc");
 return 0;
 }
-
-if (strcmp(argv[1], "smbsharesreset")==0)
+else if (strcmp(argv[1], "smbsharesreset")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/default.shares > /var/ipfire/samba/smb.conf");
 safe_system("/bin/cat /var/ipfire/samba/default.shares > /var/ipfire/samba/shares");
 return 0;
 }
-
-if (strcmp(argv[1], "smbprinterreset")==0)
+else if (strcmp(argv[1], "smbprinterreset")==0)
 {
 safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/default.printer > /var/ipfire/samba/smb.conf");
 safe_system("/bin/cat /var/ipfire/samba/default.printer > /var/ipfire/samba/printer");
 return 0;
 }
-
-if (strcmp(argv[1], "smbstop")==0)
+else if (strcmp(argv[1], "smbstop")==0)
 {
 safe_system("/etc/rc.d/init.d/samba stop >/dev/null");
-safe_system("rm -rf /etc/rc.d/rc*.d/*samba");
+safe_system("/usr/local/bin/sambactrl disable");
 return 0;
 }
-
-if (strcmp(argv[1], "smbstart")==0)
+else if (strcmp(argv[1], "smbstart")==0)
 {
 safe_system("/etc/rc.d/init.d/samba start >/dev/null");
-safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S45samba");
-safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc0.d/K48samba");
-safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc6.d/K48samba");
+safe_system("/usr/local/bin/sambactrl enable");
 return 0;
 }
-
-if (strcmp(argv[1], "smbrestart")==0)
+else if (strcmp(argv[1], "smbrestart")==0)
 {
 safe_system("/etc/rc.d/init.d/samba restart >/dev/null");
 return 0;
 }
-
-if (strcmp(argv[1], "smbreload")==0)
+else if (strcmp(argv[1], "smbreload")==0)
 {
 safe_system("/etc/rc.d/init.d/samba reload >/dev/null");
 return 0;
 }
-
-if (strcmp(argv[1], "smbstatus")==0)
+else if (strcmp(argv[1], "smbstatus")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbstatus 2>/dev/null");
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbuseradd")==0)
+else if (strcmp(argv[1], "smbuseradd")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambauser >/dev/null");
 safe_system(command);
@@ -140,8 +122,7 @@ snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpassw
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbpcadd")==0)
+else if (strcmp(argv[1], "smbpcadd")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambawks >/dev/null");
 safe_system(command);
@@ -151,8 +132,7 @@ snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -a -m %s >/dev/null", argv[
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "smbchangepw")==0)
+else if (strcmp(argv[1], "smbchangepw")==0)
 {
 snprintf(command, BUFFER_SIZE-1, "echo %s:%s | chpasswd", argv[2], argv[3]);
 safe_system(command);
@@ -160,8 +140,7 @@ snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpassw
 safe_system(command);
 return 0;
 }
-
-if (strcmp(argv[1], "readsmbpasswd")==0)
+else if (strcmp(argv[1], "readsmbpasswd")==0)
 {
 safe_system("/bin/chown root:nobody /var/ipfire/samba/private >/dev/null");
 safe_system("/bin/chown root:nobody /var/ipfire/samba/private/smbpasswd >/dev/null");
@@ -169,8 +148,7 @@ safe_system("/bin/chmod 640 /var/ipfire/samba/private/smbpasswd >/dev/null");
 safe_system("/bin/chmod 650 /var/ipfire/samba/private >/dev/null");
 return 0;
 }
-
-if (strcmp(argv[1], "locksmbpasswd")==0)
+else if (strcmp(argv[1], "locksmbpasswd")==0)
 {
 safe_system("/bin/chown root:root /var/ipfire/samba/private >/dev/null");
 safe_system("/bin/chown root:root /var/ipfire/samba/private/smbpasswd >/dev/null");
@@ -178,20 +156,17 @@ safe_system("/bin/chmod 600 /var/ipfire/samba/private/smbpasswd >/dev/null");
 safe_system("/bin/chmod 600 /var/ipfire/samba/private >/dev/null");
 return 0;
 }
-if (strcmp(argv[1], "enable")==0)
+else if (strcmp(argv[1], "enable")==0)
 {
 safe_system("touch /var/ipfire/samba/enable");
-safe_system("/etc/rc.d/init.d/samba start");
 safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S45samba");
 safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc0.d/K48samba");
 safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc6.d/K48samba");
 return 0;
 }
-
-if (strcmp(argv[1], "disable")==0)
+else if (strcmp(argv[1], "disable")==0)
 {
 safe_system("unlink /var/ipfire/samba/enable");
-safe_system("/etc/rc.d/init.d/samba stop");
 safe_system("rm -rf /etc/rc.d/rc*.d/*samba");
 return 0;
 }