mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Add start_service
and enable_service
functions to handle restating services and setting services to start on reboot.
This commit is contained in:
parent
72b95e192e
commit
2feec01e10
@ -582,7 +582,32 @@ stop_service() {
|
|||||||
if [ -x "$(command -v systemctl)" ]; then
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
systemctl stop "${1}" &> /dev/null & spinner $! || true
|
systemctl stop "${1}" &> /dev/null & spinner $! || true
|
||||||
else
|
else
|
||||||
service "${1}" &> /dev/null stop & spinner $! || true
|
service "${1}" stop &> /dev/null & spinner $! || true
|
||||||
|
fi
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
# Start/Restart service passed in as argument
|
||||||
|
# This should not fail, it's an error if it does
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Starting ${1} service..."
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart "${1}" &> /dev/null & spinner $!
|
||||||
|
else
|
||||||
|
service "${1}" restart &> /dev/null & spinner $!
|
||||||
|
fi
|
||||||
|
echo " done."
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_service() {
|
||||||
|
# Enable service so that it will start with next reboot
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Enabling ${1} service to start on reboot..."
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl enable "${1}" &> /dev/null & spinner $!
|
||||||
|
else
|
||||||
|
update-rc.d "${1}" defaults &> /dev/null & spinner $!
|
||||||
fi
|
fi
|
||||||
echo " done."
|
echo " done."
|
||||||
}
|
}
|
||||||
@ -912,8 +937,6 @@ if [[ ${useUpdateVars} == false ]]; then
|
|||||||
stop_service lighttpd
|
stop_service lighttpd
|
||||||
# Determine available interfaces
|
# Determine available interfaces
|
||||||
get_available_interfaces
|
get_available_interfaces
|
||||||
# Find IP used to route to outside world
|
|
||||||
#find_IPv4_information
|
|
||||||
# Find interfaces and let the user choose one
|
# Find interfaces and let the user choose one
|
||||||
chooseInterface
|
chooseInterface
|
||||||
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
# Let the user decide if they want to block ads over IPv4 and/or IPv6
|
||||||
@ -937,16 +960,10 @@ fi
|
|||||||
|
|
||||||
echo -n "::: Restarting services..."
|
echo -n "::: Restarting services..."
|
||||||
# Start services
|
# Start services
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
start_service dnsmasq
|
||||||
systemctl enable dnsmasq
|
enable_service dnsmasq
|
||||||
systemctl restart dnsmasq
|
start_service lighttpd
|
||||||
systemctl enable lighttpd
|
enable_service lighttpd
|
||||||
systemctl start lighttpd
|
|
||||||
else
|
|
||||||
service dnsmasq restart
|
|
||||||
service lighttpd start
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " done."
|
echo " done."
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
|
Loading…
Reference in New Issue
Block a user