-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsv-replace
30 lines (29 loc) · 1003 Bytes
/
sv-replace
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
#
# "sv-replace" script by furryfixer to replace one runit service with another.
# Invoke in the form "sv-replace <old service> <new service>"
# Useful for swapping login display managers such as XDM, LXDM, SDDM,
# or network managers, etc.
# Stops running service before replacing.
# Service names must match entries in /etc/sv
if [ "$EUID" -ne 0 ]; then
echo "You must be ROOT for this command to work"
exit 1
fi
if [ -z "$2" ] || [ ! -z "$3" ]; then
echo "Syntax error. Two and only two operands expected. "\""sv-replace A B"\"
exit 1
fi
if [ ! -e "/etc/sv/$1" ] || [ ! -e "/etc/sv/$2" ]; then
echo "Syntax error. Usage is "\""sv-replace A B"\"", where A and B services both exist in /etc/sv"
exit 1
fi
if [ ! -e "/var/service/$1" ]; then
echo $1" service not linked in /var/service/. Try "\""sv-add "$2\"" instead."
exit 1
fi
sv d $1
rm -r /var/service/$1
ln -s /etc/sv/$2 /var/service/
echo "Successfully replaced service "\"$1\"" with "\"$2\"
exit