add-rc.d rm-rc.d scripts

This commit is contained in:
wt
2024-07-05 18:49:23 +07:00
parent 916cfecee7
commit 7c88b136ef
6 changed files with 39 additions and 8 deletions
+2 -2
View File
@@ -78,11 +78,11 @@ void set_dns(const httplib::Request &request, httplib::Response &response) {
std::string new_dns_enabled = json_body["enabled"];
if (new_dns_enabled == "0") {
system("/etc/init.d/dnsmasq stop");
system("rm /etc/rc.d/60dnsmasq");
system("rm-rc.d 60dnsmasq");
syslog(LOG_INFO, "DNS is disabled");
} else {
system("/etc/init.d/dnsmasq restart");
system("ln -sv /etc/init.d/dnsmasq /etc/rc.d/60dnsmasq");
system("add-rc.d dnsmasq 60");
syslog(LOG_INFO, "DNS is enabled");
}
dnsfileout << stoi(new_dns_enabled);
+2 -2
View File
@@ -78,11 +78,11 @@ void set_ftp(const httplib::Request &request, httplib::Response &response) {
std::string new_ftp_enabled = json_body["enabled"];
if (new_ftp_enabled == "0") {
system("/etc/init.d/ftp stop");
system("rm /etc/rc.d/90ftp");
system("rm-rc 90ftp");
syslog(LOG_INFO, "Ftp is disabled");
} else {
system("/etc/init.d/ftp start");
system("ln -sv /etc/init.d/ftp /etc/rc.d/90ftp");
system("add-rc ftp 90");
syslog(LOG_INFO, "Ftp is enabled");
}
ftpfileout << stoi(new_ftp_enabled);
+2 -2
View File
@@ -77,11 +77,11 @@ void set_ssh_status(const httplib::Request &request, httplib::Response &response
std::string new_ssh_status = json_body["status"];
if (new_ssh_status == "0") {
system("/etc/init.d/ssh stop");
system("rm /etc/rc.d/75ssh");
system("rm-rc.d 75ssh");
syslog(LOG_INFO, "SSH is disabled");
} else {
system("/etc/init.d/ssh start");
system("ln -sv /etc/init.d/ssh /etc/rc.d/75ssh");
system("add-rc.d ssh 75");
syslog(LOG_INFO, "SSH is enabled");
}
sshfileout << stoi(new_ssh_status);
+2 -2
View File
@@ -82,11 +82,11 @@ void set_telnet(const httplib::Request &request, httplib::Response &response) {
std::string new_telnet_enabled = json_body["enabled"];
if (new_telnet_enabled == "0") {
system("/etc/init.d/telnet stop");
system("rm /etc/rc.d/70telnet");
system("rm-rc.d 70telnet");
syslog(LOG_INFO, "Telnet is disabled");
} else {
system("/etc/init.d/telnet start");
system("ln -sv /etc/init.d/telnet /etc/rc.d/70telnet");
system("add-rc.d telnet 70");
syslog(LOG_INFO, "Telnet is enabled");
}
telnetfileout << stoi(new_telnet_enabled);
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
if [ -f /etc/init.d/$1 ] && [ "$2" -gt 0 ]; then
cd /etc/rc.d
ln -sv ../init.d/$1 "$2$1"
echo "added $1 to init."
else
echo "
** add-rc.d usage:
add-rc.d [init.d script name] [order number]
examples:
add-rc.d httpd 40
add-rc.d ftpd 40
add-rc.d telnetd 50
"
fi
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
if [ -f /etc/rc.d/$1 ]; then
rm -v /etc/rc.d/$1
echo "removed $1 from init."
else
echo "
** rm-rc.d usage:
rm-rc.d [rc.d link name]
examples:
rm-rc.d 40httpd
rm-rc.d 40ftpd
rm-rc.d 50telnetd
"
fi