rc script, pm - package manger and update init scripts
This commit is contained in:
1 parent
7c88b136ef
commit
31717c44b6
40 files changed
+569
-231
No files matched your search
@@ -77,12 +77,12 @@ void set_dns(const httplib::Request &request, httplib::Response &response) {
|
|||||||
std::ofstream dnsfileout("/etc/openrouter/dns");
|
std::ofstream dnsfileout("/etc/openrouter/dns");
|
||||||
std::string new_dns_enabled = json_body["enabled"];
|
std::string new_dns_enabled = json_body["enabled"];
|
||||||
if (new_dns_enabled == "0") {
|
if (new_dns_enabled == "0") {
|
||||||
system("/etc/init.d/dnsmasq stop");
|
system("rc stop dnsmasq");
|
||||||
system("rm-rc.d 60dnsmasq");
|
system("rc del dnsmasq");
|
||||||
syslog(LOG_INFO, "DNS is disabled");
|
syslog(LOG_INFO, "DNS is disabled");
|
||||||
} else {
|
} else {
|
||||||
system("/etc/init.d/dnsmasq restart");
|
system("rc restart dnsmasq");
|
||||||
system("add-rc.d dnsmasq 60");
|
system("rc add dnsmasq");
|
||||||
syslog(LOG_INFO, "DNS is enabled");
|
syslog(LOG_INFO, "DNS is enabled");
|
||||||
}
|
}
|
||||||
dnsfileout << stoi(new_dns_enabled);
|
dnsfileout << stoi(new_dns_enabled);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void set_local_domains(const httplib::Request &request, httplib::Response &respo
|
|||||||
domainsfile << ip << " " << dom << "\n";
|
domainsfile << ip << " " << dom << "\n";
|
||||||
}
|
}
|
||||||
domainsfile.close();
|
domainsfile.close();
|
||||||
system("/etc/init.d/dnsmasq restart");
|
system("rc restart dnsmasq");
|
||||||
syslog(LOG_INFO, "DNS local domains changed");
|
syslog(LOG_INFO, "DNS local domains changed");
|
||||||
std::string responsedata = R"({"success":"true"})";
|
std::string responsedata = R"({"success":"true"})";
|
||||||
response.set_content(responsedata, JSON_TYPE);
|
response.set_content(responsedata, JSON_TYPE);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void set_dns_servers(const httplib::Request &request, httplib::Response &respons
|
|||||||
dnsserversfile << "nameserver " << srv << "\n";
|
dnsserversfile << "nameserver " << srv << "\n";
|
||||||
}
|
}
|
||||||
dnsserversfile.close();
|
dnsserversfile.close();
|
||||||
system("/etc/init.d/dnsmasq restart");
|
system("rc restart dnsmasq");
|
||||||
syslog(LOG_INFO, "DNS servers changed");
|
syslog(LOG_INFO, "DNS servers changed");
|
||||||
std::string responsedata = R"({"success":"true"})";
|
std::string responsedata = R"({"success":"true"})";
|
||||||
response.set_content(responsedata, JSON_TYPE);
|
response.set_content(responsedata, JSON_TYPE);
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ void set_ftp(const httplib::Request &request, httplib::Response &response) {
|
|||||||
std::ofstream ftpfileout("/etc/openrouter/ftp");
|
std::ofstream ftpfileout("/etc/openrouter/ftp");
|
||||||
std::string new_ftp_enabled = json_body["enabled"];
|
std::string new_ftp_enabled = json_body["enabled"];
|
||||||
if (new_ftp_enabled == "0") {
|
if (new_ftp_enabled == "0") {
|
||||||
system("/etc/init.d/ftp stop");
|
system("rc stop ftp");
|
||||||
system("rm-rc 90ftp");
|
system("rc del ftp");
|
||||||
syslog(LOG_INFO, "Ftp is disabled");
|
syslog(LOG_INFO, "Ftp is disabled");
|
||||||
} else {
|
} else {
|
||||||
system("/etc/init.d/ftp start");
|
system("rc start ftp");
|
||||||
system("add-rc ftp 90");
|
system("rc add ftp");
|
||||||
syslog(LOG_INFO, "Ftp is enabled");
|
syslog(LOG_INFO, "Ftp is enabled");
|
||||||
}
|
}
|
||||||
ftpfileout << stoi(new_ftp_enabled);
|
ftpfileout << stoi(new_ftp_enabled);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void set_ssh_keys(const httplib::Request &request, httplib::Response &response)
|
|||||||
keysfile << key << "\n";
|
keysfile << key << "\n";
|
||||||
}
|
}
|
||||||
keysfile.close();
|
keysfile.close();
|
||||||
system("/etc/init.d/ssh restart");
|
system("rc restart ssh");
|
||||||
syslog(LOG_INFO, "SSH keys changed");
|
syslog(LOG_INFO, "SSH keys changed");
|
||||||
std::string responsedata = R"({"success":"true"})";
|
std::string responsedata = R"({"success":"true"})";
|
||||||
response.set_content(responsedata, JSON_TYPE);
|
response.set_content(responsedata, JSON_TYPE);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void set_ssh_port(const httplib::Request &request, httplib::Response &response)
|
|||||||
systemrequest << "sed -i \"/Port " << old_ssh_port << "/s//Port " << new_ssh_port << "/\" /etc/ssh/sshd_config";
|
systemrequest << "sed -i \"/Port " << old_ssh_port << "/s//Port " << new_ssh_port << "/\" /etc/ssh/sshd_config";
|
||||||
std::cout << systemrequest.str() << std::endl;
|
std::cout << systemrequest.str() << std::endl;
|
||||||
system(systemrequest.str().c_str());
|
system(systemrequest.str().c_str());
|
||||||
system("/etc/init.d/ssh restart");
|
system("rc restart ssh");
|
||||||
std::string syslogstring = "SSH port changed to " + new_ssh_port;
|
std::string syslogstring = "SSH port changed to " + new_ssh_port;
|
||||||
syslog(LOG_INFO, syslogstring.c_str());
|
syslog(LOG_INFO, syslogstring.c_str());
|
||||||
std::ifstream sshportfile(SSH_PORT_PATH);
|
std::ifstream sshportfile(SSH_PORT_PATH);
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ void set_ssh_status(const httplib::Request &request, httplib::Response &response
|
|||||||
std::ofstream sshfileout("/etc/openrouter/ssh/status");
|
std::ofstream sshfileout("/etc/openrouter/ssh/status");
|
||||||
std::string new_ssh_status = json_body["status"];
|
std::string new_ssh_status = json_body["status"];
|
||||||
if (new_ssh_status == "0") {
|
if (new_ssh_status == "0") {
|
||||||
system("/etc/init.d/ssh stop");
|
system("rc stop ssh");
|
||||||
system("rm-rc.d 75ssh");
|
system("rc del ssh");
|
||||||
syslog(LOG_INFO, "SSH is disabled");
|
syslog(LOG_INFO, "SSH is disabled");
|
||||||
} else {
|
} else {
|
||||||
system("/etc/init.d/ssh start");
|
system("rc start ssh");
|
||||||
system("add-rc.d ssh 75");
|
system("rc add ssh");
|
||||||
syslog(LOG_INFO, "SSH is enabled");
|
syslog(LOG_INFO, "SSH is enabled");
|
||||||
}
|
}
|
||||||
sshfileout << stoi(new_ssh_status);
|
sshfileout << stoi(new_ssh_status);
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ void set_telnet(const httplib::Request &request, httplib::Response &response) {
|
|||||||
std::ofstream telnetfileout("/etc/openrouter/telnet/enabled");
|
std::ofstream telnetfileout("/etc/openrouter/telnet/enabled");
|
||||||
std::string new_telnet_enabled = json_body["enabled"];
|
std::string new_telnet_enabled = json_body["enabled"];
|
||||||
if (new_telnet_enabled == "0") {
|
if (new_telnet_enabled == "0") {
|
||||||
system("/etc/init.d/telnet stop");
|
system("rc stop telnet");
|
||||||
system("rm-rc.d 70telnet");
|
system("rc del telnet");
|
||||||
syslog(LOG_INFO, "Telnet is disabled");
|
syslog(LOG_INFO, "Telnet is disabled");
|
||||||
} else {
|
} else {
|
||||||
system("/etc/init.d/telnet start");
|
system("rc start telnet");
|
||||||
system("add-rc.d telnet 70");
|
system("rc add telnet");
|
||||||
syslog(LOG_INFO, "Telnet is enabled");
|
syslog(LOG_INFO, "Telnet is enabled");
|
||||||
}
|
}
|
||||||
telnetfileout << stoi(new_telnet_enabled);
|
telnetfileout << stoi(new_telnet_enabled);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void set_telnet_port(const httplib::Request &request, httplib::Response &respons
|
|||||||
std::string new_telnet_port = json_body["port"];
|
std::string new_telnet_port = json_body["port"];
|
||||||
telnetportfileout << stoi(new_telnet_port);
|
telnetportfileout << stoi(new_telnet_port);
|
||||||
telnetportfileout.close();
|
telnetportfileout.close();
|
||||||
system("/etc/init.d/telnet restart");
|
system("rc restart telnet");
|
||||||
std::string syslogstring = "Telnet port changed to " + new_telnet_port;
|
std::string syslogstring = "Telnet port changed to " + new_telnet_port;
|
||||||
syslog(LOG_INFO, syslogstring.c_str());
|
syslog(LOG_INFO, syslogstring.c_str());
|
||||||
std::ifstream telnetportfile("/etc/openrouter/telnet/port");
|
std::ifstream telnetportfile("/etc/openrouter/telnet/port");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
interface=eth1
|
interface=eth1
|
||||||
dhcp-range=interface:eth0,192.168.100.2,192.168.100.100,12h
|
dhcp-range=interface:eth1,192.168.100.2,192.168.100.100,12h
|
||||||
dhcp-range=interface:wlan0,192.168.101.2,192.168.101.100,12h
|
dhcp-range=interface:wlan0,192.168.101.2,192.168.101.100,12h
|
||||||
resolv-file=/etc/dnsmasq.conf.d/resolv.conf
|
resolv-file=/etc/dnsmasq.conf.d/resolv.conf
|
||||||
addn-hosts=/etc/dnsmasq.conf.d/hosts
|
addn-hosts=/etc/dnsmasq.conf.d/hosts
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
root:x:0:root
|
root:x:0:root
|
||||||
dnsmasq:x:963:
|
dnsmasq:x:963:
|
||||||
sshd:x:33:sshd
|
sshd:x:33:sshd
|
||||||
|
nobody:x:65534:
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
root:x:0:root
|
root:x:0:root
|
||||||
dnsmasq:x:963:
|
dnsmasq:x:963:
|
||||||
sshd:x:33:
|
sshd:x:33:
|
||||||
|
nobody:x:65534:65534:Kernel Overflow User:/:/usr/bin/nologin
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
::1 localhost
|
::1 localhost
|
||||||
127.0.1.1 Simple.localdomain
|
127.0.1.1 Simple.localdomain Simple
|
||||||
+6
-14
@@ -3,29 +3,21 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting dnsd "
|
notify "Starting dnsd "
|
||||||
# sleep 10
|
# sleep 10
|
||||||
/usr/bin/dnsd -d -c /etc/dnsd.conf
|
/usr/bin/dnsd -d -c /etc/dnsd.conf
|
||||||
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
|
||||||
echo $(pgrep dnsd) > /var/run/dnsd.pid
|
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping dnsd "
|
notify "Stopping dnsd "
|
||||||
kill $(cat /var/run/dnsd.pid) &> /dev/null
|
kill $(cat /var/run/dnsd.pid) &> /dev/null
|
||||||
rm /var/run/dnsd.pid
|
rm /var/run/dnsd.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
@@ -3,31 +3,24 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting dnsmasq "
|
notify "Starting dnsmasq "
|
||||||
sleep 1
|
sleep 1
|
||||||
/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
|
/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
|
||||||
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
echo "nameserver 0.0.0.0" > /etc/resolv.conf
|
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "\nStopping dnsmasq "
|
notify "\nStopping dnsmasq "
|
||||||
if [ -f /var/run/dnsmasq.pid ]; then
|
if [ -f /var/run/dnsmasq.pid ]; then
|
||||||
kill $(cat /var/run/dnsmasq.pid) &> /dev/null
|
kill $(cat /var/run/dnsmasq.pid) &> /dev/null
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
rm /var/run/dnsmasq &> /dev/null
|
rm /var/run/dnsmasq &> /dev/null
|
||||||
else
|
else
|
||||||
printf "[$Red Dnsmasq is not running $Color_off]\n"
|
notify "[$Red Dnsmasq is not running $Color_off]\n"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
|
|||||||
+6
-12
@@ -3,27 +3,21 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting fptd "
|
notify "Starting fptd "
|
||||||
tcpsvd -vE 0.0.0.0 21 ftpd -w -S -A $(cat /etc/openrouter/ftppath) &>/dev/null &
|
tcpsvd -vE 0.0.0.0 21 ftpd -w -S -A $(cat /etc/openrouter/ftppath) &>/dev/null &
|
||||||
echo $! > /var/run/ftpd.pid
|
echo $! > /var/run/ftpd.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Cpolor_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping ftpd "
|
notify "Stopping ftpd "
|
||||||
kill $(cat /var/run/ftpd.pid)
|
kill $(cat /var/run/ftpd.pid)
|
||||||
killall ftpd
|
killall ftpd
|
||||||
rm /var/run/ftpd.pid
|
rm /var/run/ftpd.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Setting up hostname "
|
notify "Setting up hostname "
|
||||||
/bin/hostname -F /etc/hostname
|
/bin/hostname -F /etc/hostname
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -3,26 +3,20 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting httpd "
|
notify "Starting httpd "
|
||||||
httpd -h /srv/www &> /dev/null
|
httpd -h /srv/www &> /dev/null
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Cpolor_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping httpd "
|
notify "Stopping httpd "
|
||||||
killall httpd
|
killall httpd
|
||||||
#kill $(cat /var/run/httpd.pid)
|
#kill $(cat /var/run/httpd.pid)
|
||||||
#rm /var/run/httpd.pid
|
#rm /var/run/httpd.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
Green='\033[0;32m'
|
||||||
|
Color_Off='\033[0m'
|
||||||
|
Red='\033[0;31m'
|
||||||
|
|
||||||
init () {
|
init () {
|
||||||
test -f $DAEMON || exit 0
|
test -f $DAEMON || exit 0
|
||||||
@@ -58,3 +61,15 @@ sleep 1
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check() {
|
||||||
|
if [[ "$1" == "0" ]];then
|
||||||
|
printf "[$Green OK $Color_Off]\n"
|
||||||
|
else
|
||||||
|
printf "[$Red ERR $Cpolor_Off]\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
notify() {
|
||||||
|
printf "$*"
|
||||||
|
}
|
||||||
@@ -8,27 +8,21 @@ DAEMON="iptables"
|
|||||||
|
|
||||||
IPTABLES_ARGS=""
|
IPTABLES_ARGS=""
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
printf 'Starting %s: ' "$DAEMON"
|
notify "Starting $DAEMON"
|
||||||
iptables-restore /etc/iptables.conf
|
iptables-restore /etc/iptables.conf
|
||||||
status=$?
|
status=$?
|
||||||
if [ "$status" -eq 0 ]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
return "$status"
|
return "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
printf 'Stopping %s: ' "$DAEMON"
|
notify "Stopping $DAEMON"
|
||||||
iptables -F
|
iptables -F
|
||||||
status=$?
|
status=$?
|
||||||
if [ "$status" -eq 0 ]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
return "$status"
|
return "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,11 +33,11 @@ restart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
printf 'Saving %s: ' "$DAEMON"
|
notify 'Saving %s: ' "$DAEMON"
|
||||||
iptables-save -f /etc/iptables.conf
|
iptables-save -f /etc/iptables.conf
|
||||||
status=$?
|
status=$?
|
||||||
if [ "$status" -eq 0 ]; then
|
if [ "$status" -eq 0 ]; then
|
||||||
printf "[$Green OK $Color_off]\n"
|
notify "[$Green OK $Color_off]\n"
|
||||||
else
|
else
|
||||||
echo "SKIP (read-only file system detected)"
|
echo "SKIP (read-only file system detected)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+7
-13
@@ -3,28 +3,22 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting klogd "
|
notify "Starting klogd "
|
||||||
klogd
|
klogd
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping klogd "
|
notify "Stopping klogd "
|
||||||
if [ -f /var/run/klogd.pid ]; then
|
if [ -f /var/run/klogd.pid ]; then
|
||||||
kill $(cat /var/run/klogd.pid)
|
kill $(cat /var/run/klogd.pid)
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
rm /var/run/klogd.pid &> /dev/null
|
rm /var/run/klogd.pid &> /dev/null
|
||||||
else
|
else
|
||||||
printf "[$Red Klogd is not running $Color_off]\n"
|
notify "[$Red Klogd is not running $Color_off]\n"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
|
|||||||
@@ -3,26 +3,20 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting networking "
|
notify "Starting networking "
|
||||||
/usr/bin/ifup -a &>/dev/null &
|
/usr/bin/ifup -a &>/dev/null &
|
||||||
echo $! > /var/run/networking.pid
|
echo $! > /var/run/networking.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Cpolor_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping networking "
|
notify "Stopping networking "
|
||||||
/usr/bin/ifdown -a
|
/usr/bin/ifdown -a
|
||||||
rm /var/run/networking.pid
|
rm /var/run/networking.pid
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
+6
-12
@@ -3,24 +3,18 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting nginx "
|
notify "Starting nginx "
|
||||||
nginx
|
nginx
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping nginx "
|
notify "Stopping nginx "
|
||||||
nginx -s stop
|
nginx -s stop
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
@@ -3,26 +3,20 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting openrouter software "
|
notify "Starting openrouter software "
|
||||||
cd /srv/ftpd/auth_service_router/bin && ./auth_service &> /dev/null &
|
cd /srv/ftpd/auth_service_router/bin && ./auth_service &> /dev/null &
|
||||||
cd /srv/ftpd/openrouter_adminpanel/bin && ./openrouter &> /dev/null &
|
cd /srv/ftpd/openrouter_adminpanel/bin && ./openrouter &> /dev/null &
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Cpolor_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping openrouter software "
|
notify "Stopping openrouter software "
|
||||||
killall openrouter
|
killall openrouter
|
||||||
killall auth_service
|
killall auth_service
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
+6
-12
@@ -3,24 +3,18 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting sshd "
|
notify "Starting sshd "
|
||||||
/usr/bin/sshd -D &
|
/usr/bin/sshd -D &
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping sshd "
|
notify "Stopping sshd "
|
||||||
killall sshd
|
killall sshd
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
+6
-12
@@ -3,24 +3,18 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Configuring swap "
|
notify "Configuring swap "
|
||||||
swapon -a
|
swapon -a
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping use swap "
|
notify "Stopping use swap "
|
||||||
swapoff -a
|
swapoff -a
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ Green='\033[0;32m'
|
|||||||
Color_Off='\033[0m'
|
Color_Off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Setting up sysctl "
|
notify "Setting up sysctl "
|
||||||
sysctl -p &> /dev/null
|
sysctl -p &> /dev/null
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_Off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_Off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -3,28 +3,22 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting syslogd "
|
notify "Starting syslogd "
|
||||||
syslogd
|
syslogd
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping syslogd "
|
notify "Stopping syslogd "
|
||||||
if [ -f /var/run/syslogd.pid ]; then
|
if [ -f /var/run/syslogd.pid ]; then
|
||||||
kill $(cat /var/run/syslogd.pid)
|
kill $(cat /var/run/syslogd.pid)
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
rm /var/run/syslogd.pid &> /dev/null
|
rm /var/run/syslogd.pid &> /dev/null
|
||||||
else
|
else
|
||||||
printf "[$Red Syslogd is not running $Color_off]\n"
|
notify "[$Red Syslogd is not running $Color_off]\n"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
|
|||||||
@@ -3,24 +3,18 @@ Green='\033[0;32m'
|
|||||||
Color_off='\033[0m'
|
Color_off='\033[0m'
|
||||||
Red='\033[0;31m'
|
Red='\033[0;31m'
|
||||||
|
|
||||||
|
. /etc/init.d/init-functions
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
printf "Starting telnet "
|
notify "Starting telnet "
|
||||||
telnetd -p $(cat /etc/openrouter/telnet/port)
|
telnetd -p $(cat /etc/openrouter/telnet/port)
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
printf "Stopping telnet "
|
notify "Stopping telnet "
|
||||||
killall telnetd
|
killall telnetd
|
||||||
if [[ "$?" == "0" ]]; then
|
check $?
|
||||||
printf "[$Green OK $Color_off]\n"
|
|
||||||
else
|
|
||||||
printf "[$Red ERR $Color_off]\n"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
"$0" stop
|
"$0" stop
|
||||||
|
|||||||
+11
-1
@@ -1 +1,11 @@
|
|||||||
Simple \r (\l)
|
\h \r (\l)
|
||||||
|
########## ## #### #### ########## ## ##########
|
||||||
|
########## ## #### #### ########## ## ##########
|
||||||
|
## ## ## ## ## ## ## ## ##
|
||||||
|
## ## ## ## ## ## ## ## ## ##
|
||||||
|
########## ## ## ## ## ########## ## ##########
|
||||||
|
########## ## ## ## ## ########## ## ##########
|
||||||
|
## ## ## ## ## ## ##
|
||||||
|
## ## ## ## ## ## ##
|
||||||
|
########## ## ## ## ## ########## ##########
|
||||||
|
########## ## ## ## ## ########## ##########
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
root:x:0:0:root:/root:/bin/sh
|
root:x:0:0:root:/root:/bin/sh
|
||||||
dnsmasq:x:963:963:dnsmasq daemon:/:/usr/bin/nologin
|
dnsmasq:x:963:963:dnsmasq daemon:/:/usr/bin/nologin
|
||||||
sshd:x:33:33:SSH daemon:/var/lib/sshd:/bin/sh
|
sshd:x:33:33:SSH daemon:/var/lib/sshd:/bin/sh
|
||||||
|
nobody:x:65534:65534:Kernel Overflow User:/:/usr/bin/nologin
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
http://localhost/
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
root:F.fHA5x2Q.xNY:19797::::::
|
root:F.fHA5x2Q.xNY:19797::::::
|
||||||
dnsmasq:!*:19889::::::
|
dnsmasq:!*:19889::::::
|
||||||
sshd:!:19906:0:99999:7:::
|
sshd:!:19906:0:99999:7:::
|
||||||
|
nobody:!*:19889::::::
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/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
|
|
||||||
Executable
+284
@@ -0,0 +1,284 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
########## #### ####
|
||||||
|
########## #### ####
|
||||||
|
## ## ## ## ## ##
|
||||||
|
## ## ## ## ## ##
|
||||||
|
########## ## ## ## - PACKAGE MANAGER FOR SIMPLE LINUX
|
||||||
|
########## ## ## ## - AUTHOR -- TOLA MIRONCENKO
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
## ## ##
|
||||||
|
|
||||||
|
#----- colors -------
|
||||||
|
Green='\033[0;32m'
|
||||||
|
Color_off='\033[0m'
|
||||||
|
Red='\033[0;31m'
|
||||||
|
Bred='\033[1;31m'
|
||||||
|
Yellow='\033[1;33m'
|
||||||
|
White='\033[0;37m'
|
||||||
|
Bwhite='\033[1;37m'
|
||||||
|
#--------------------
|
||||||
|
|
||||||
|
#---------------- variables --------------------------
|
||||||
|
rootdir=/
|
||||||
|
repofile=$rootdir/etc/pm/repo
|
||||||
|
packagesqueryfile=$rootdir/usr/share/pm/query
|
||||||
|
reposquerydir=$rootdir/usr/share/pm/repos
|
||||||
|
cachedpkgdir=$rootdir/var/cache/pm/pkg
|
||||||
|
installedpackagesdir=$rootdir/usr/share/pm/packages
|
||||||
|
#-----------------------------------------------------
|
||||||
|
|
||||||
|
#---------------- check root priveleges function ------------------------
|
||||||
|
checkroot() {
|
||||||
|
if [[ $(id -u) != 0 ]]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off you must be root\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
checkroot
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#----------------- add(install) package function ------------------------
|
||||||
|
add() {
|
||||||
|
if [[ ! $1 ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
down $i
|
||||||
|
done
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "add" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
unpack $cachedpkgdir/$i.pkg.gz
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------------- download package without install function ---------
|
||||||
|
down() {
|
||||||
|
if [[ ! $1 ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
if [[ $j == $1 ]]; then
|
||||||
|
if [ ! -f $cachedpkgdir/$1.pkg.gz ]; then
|
||||||
|
printf "$Yellow**$Color_off Downloading $Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
wget $i/$1.pkg.gz -P $cachedpkgdir
|
||||||
|
if [[ "$?" == "0" ]]; then
|
||||||
|
printf "$Yellow**$Green successful downloaded $1\n$Color_off"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't download package\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "$Yellow**$Green successful downloaded $1\n$Color_off"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't find package $1\n"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------------- unpack local package archive ----------------------
|
||||||
|
unpack() {
|
||||||
|
packagename=$(echo $1 | sed -e "/.gz/s///")
|
||||||
|
packagename=${packagename#*pkg/}
|
||||||
|
printf "$Yellow**$Green Installing ${packagename%.pkg*}\n$Color_off"
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep ${packagename%.pkg*})" != "" ]]; then
|
||||||
|
printf "$Yellow**$Color_off Package already installed:$Yellow reinstalling\n"
|
||||||
|
fi
|
||||||
|
tar -xvf $1 -C $rootdir/tmp &> /dev/null
|
||||||
|
cd $rootdir/tmp/$packagename
|
||||||
|
mkdir $installedpackagesdir/$packagename &> /dev/null
|
||||||
|
mv -v list $installedpackagesdir/$packagename &> /dev/null
|
||||||
|
cp -rv ./* $rootdir &> /dev/null
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep ${packagename%.pkg*})" == "" ]]; then
|
||||||
|
echo ${packagename%.pkg*} >> $packagesqueryfile
|
||||||
|
fi
|
||||||
|
rm -rv $rootdir/tmp/$packagename &> /dev/null
|
||||||
|
printf "$Yellow**$Green Installed ${packagename%.pkg*} successful\n$Color_off"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------ delete package function -----------------------------
|
||||||
|
del() {
|
||||||
|
printf "$Yellow**$Green deleting\n$Color_off"
|
||||||
|
for i in $*; do
|
||||||
|
if [[ "$i" == "del" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
printf "$Yellow**$Green deleting $i\n$Color_off"
|
||||||
|
if [ ! -f $installedpackagesdir/$i.pkg/list ]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off package not installed\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
rm -v $rootdir/$(cat $installedpackagesdir/$i.pkg/list) &> /dev/null
|
||||||
|
rm -rv $installedpackagesdir/$i.pkg &> /dev/null
|
||||||
|
sed -i "/$i/d" $packagesqueryfile
|
||||||
|
printf "$Yellow**$Green delete $i successful\n$Color_off"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- list files in package function ---------------------
|
||||||
|
list() {
|
||||||
|
if [[ "$1" == "" ]]; then
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ "$(cat $packagesqueryfile | grep $1)" == "" ]]; then
|
||||||
|
printf "$Yellow**$Bred error:$Color_off package is not installed\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
filelist=$(cat $installedpackagesdir/$1.pkg/list)
|
||||||
|
for i in $filelist; do
|
||||||
|
printf "$Yellow$1: $Bwhite$i$Color_off\n"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- show installed packages function -------------------
|
||||||
|
query() {
|
||||||
|
packagesquery=$(cat $packagesqueryfile)
|
||||||
|
if [[ "$packagesquery" == "" ]]; then
|
||||||
|
printf "$Yellow**$Bwhite No installed packages\n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
printf "$Bwhite$packagesquery$Color_off\n"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------- show help function -------------------------------
|
||||||
|
help() {
|
||||||
|
printf "
|
||||||
|
$Yellow**$Green pm usage$Color_off :
|
||||||
|
$Bwhite pm add [package name] - download and install from repository
|
||||||
|
pm unpack [/path/to/package/archive] - unpack(install) from local package archive
|
||||||
|
pm down [package name] - download package from repository without install
|
||||||
|
pm del [package name] - delete package
|
||||||
|
pm list [package name] - list files in package
|
||||||
|
pm search [package name] - search package in repository
|
||||||
|
pm query - show installed packages
|
||||||
|
pm help - this help message
|
||||||
|
pm clear - clear all package archives from cached packages directory
|
||||||
|
pm sync - synchronize repository
|
||||||
|
|
||||||
|
$Yellow**$Green examples$Color_off :
|
||||||
|
$Bwhite pm add dnsmasq
|
||||||
|
pm unpack ./dnsmasq.pkg.gz
|
||||||
|
pm down dnsmasq
|
||||||
|
pm search dnsmasq
|
||||||
|
pm help
|
||||||
|
pm clear
|
||||||
|
pm sync
|
||||||
|
pm del dnsmasq
|
||||||
|
pm list dnsmasq
|
||||||
|
pm query
|
||||||
|
\n$Color_off"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- sync repo function ---------------------------------
|
||||||
|
sync() {
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\//s///")
|
||||||
|
mkdir $reposquerydir/$serverdir &> /dev/null
|
||||||
|
wget $i/query -O $reposquerydir/$serverdir/query &> /dev/null
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#----------------- search package in repo function ----------------------
|
||||||
|
search() {
|
||||||
|
servers=$(cat $repofile)
|
||||||
|
if [[ ! $1 ]]; then
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
printf "$Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $servers; do
|
||||||
|
serverdir=$(echo $i | sed -e "/http:\/\//s///")
|
||||||
|
repoquery=$(cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
|
||||||
|
for j in $repoquery; do
|
||||||
|
if [[ $j == $1 ]]; then
|
||||||
|
printf "$Yellow$serverdir: $Bwhite$j\n$Color_off"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
printf "$Yellow**$Red error:$Color_off can't find package ($1)\n"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------- clear cached packages directory --------------------
|
||||||
|
clear() {
|
||||||
|
rm -v $cachedpkgdir/*
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
add)
|
||||||
|
add $*
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
down $2
|
||||||
|
;;
|
||||||
|
unpack)
|
||||||
|
unpack $2
|
||||||
|
;;
|
||||||
|
del)
|
||||||
|
del $*
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
list $2
|
||||||
|
;;
|
||||||
|
query)
|
||||||
|
query
|
||||||
|
;;
|
||||||
|
help)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
sync
|
||||||
|
;;
|
||||||
|
search)
|
||||||
|
search $2
|
||||||
|
;;
|
||||||
|
clear)
|
||||||
|
clear
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Executable
+124
@@ -0,0 +1,124 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
########## ##########
|
||||||
|
########## ##########
|
||||||
|
## ## ##
|
||||||
|
## ##
|
||||||
|
## ## - RC BOOT SCRIPTS MANAGER FOR SIMPLE LINUX
|
||||||
|
## ## - AUTHOR -- TOLA MIRONCENKO
|
||||||
|
## ##
|
||||||
|
## ##
|
||||||
|
## ##########
|
||||||
|
## ##########
|
||||||
|
|
||||||
|
#------------------------ add to boot function --------------
|
||||||
|
add() {
|
||||||
|
resultlink=$(cat /usr/share/rc/ordernumbers | grep $1)
|
||||||
|
if [ -f /etc/init.d/$1 ] && [ $resultlink ]; then
|
||||||
|
cd /etc/rc.d
|
||||||
|
ln -sv ../init.d/$1 "$resultlink" &> /dev/null
|
||||||
|
echo "added $1 to init."
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------- del from boot function ---------------
|
||||||
|
del() {
|
||||||
|
filetoremove=$(find /etc/rc.d/ | grep $1 )
|
||||||
|
if [ $filetoremove ]; then
|
||||||
|
rm -v $filetoremove &> /dev/null
|
||||||
|
echo "removed $1 from init."
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#---------------------- start daemon function ---------------
|
||||||
|
start() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 start
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#---------------- stop daemon function ----------------------
|
||||||
|
stop() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 stop
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------- restart daemon function ----------------------
|
||||||
|
restart() {
|
||||||
|
if [ -f /etc/init.d/$1 ]; then
|
||||||
|
/etc/init.d/$1 restart
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#-------------- print help function -------------------------
|
||||||
|
help() {
|
||||||
|
echo "
|
||||||
|
** rc usage:
|
||||||
|
rc add [init.d script name]
|
||||||
|
rc del [init.d script name]
|
||||||
|
rc start [init.d script name]
|
||||||
|
rc stop [init.d script name]
|
||||||
|
rc restart [init.d script name]
|
||||||
|
|
||||||
|
examples:
|
||||||
|
rc add httpd
|
||||||
|
rc add ftpd
|
||||||
|
rc add telnetd
|
||||||
|
|
||||||
|
rc del httpd
|
||||||
|
rc del ftpd
|
||||||
|
rc del telnetd
|
||||||
|
|
||||||
|
rc start httpd
|
||||||
|
rc start ftpd
|
||||||
|
rc start telnetd
|
||||||
|
|
||||||
|
rc stop httpd
|
||||||
|
rc stop ftpd
|
||||||
|
rc stop telnetd
|
||||||
|
|
||||||
|
rc restart httpd
|
||||||
|
rc restart ftpd
|
||||||
|
rc restart telnetd
|
||||||
|
"
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
command="$1"
|
||||||
|
|
||||||
|
case ${command} in
|
||||||
|
add)
|
||||||
|
add $2 $3
|
||||||
|
;;
|
||||||
|
del)
|
||||||
|
del $2
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
start $2
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop $2
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
restart $2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/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
|
|
||||||
Whitespace-only changes.
@@ -0,0 +1,2 @@
|
|||||||
|
fet.sh.pkg.gz
|
||||||
|
pfetch.pkg.gz
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
15hostname
|
||||||
|
20klogd
|
||||||
|
30syslogd
|
||||||
|
40swap
|
||||||
|
50networking
|
||||||
|
55sysctl
|
||||||
|
60dnsmasq
|
||||||
|
65dnsd
|
||||||
|
70telnet
|
||||||
|
75ssh
|
||||||
|
80iptables
|
||||||
|
85openrouterinit
|
||||||
|
90ftp
|
||||||
|
95nginx
|
||||||
Reference in new issue
Block a user