10 # Service messages section
11 CONTINMSG="$BLUE Press any key to continue$NC"
12 ERRORMSG="$RED Wrong.$NC"
13 TRYAGAINMSG="$RED Press any key and try again$NC"
14 SELECTFILEMSG="Select file to configure and press Enter: "
15 SELECTTARGETMSG="Select target and press Enter to change to: "
16 SERVICEPREFIXMSG="Service "
17 SERVICESTARTEDMSG=" was started successfully"
18 SERVICEENABLEDMSG=" was enabled successfully"
19 SERVICESTOPPEDMSG=" was stopped successfully"
20 SERVICEDISABLEDMSG=" was disabled successfully"
22 function pressanykeyrequest {
28 function config_editor {
30 configs=("journald.conf" "system.conf" "logind.conf" "user.conf" "cancel")
32 select pick in "${configs[@]}"
36 [ -e /etc/systemd/logind.conf.d/10-logind.conf ] || \
37 sudo mkdir -p /etc/systemd/logind.conf.d/ && \
38 sudo cp /etc/systemd/logind.conf /etc/systemd/logind.conf.d/10-logind.conf && \
39 sudo $TEXTEDITOR /etc/systemd/logind.conf.d/10-logind.conf
43 [ -e /etc/systemd/system.conf.d/10-system.conf ] || \
44 sudo mkdir -p /etc/systemd/system.conf.d/ && \
45 sudo cp /etc/systemd/system.conf /etc/systemd/system.conf.d/10-system.conf && \
46 sudo $TEXTEDITOR /etc/systemd/system.conf.d/10-system.conf
50 [ -e /etc/systemd/journald.conf.d/10-journald.conf ] || \
51 sudo mkdir -p /etc/systemd/journald.conf.d/ && \
52 sudo cp /etc/systemd/journald.conf /etc/systemd/journald.conf.d/10-journald.conf && \
53 sudo $TEXTEDITOR /etc/systemd/journald.conf.d/10-journald.conf
57 [ -e /etc/systemd/user.conf.d/10-user.conf ] || \
58 sudo mkdir -p /etc/systemd/user.conf.d/ && \
59 sudo cp /etc/systemd/user.conf /etc/systemd/user.conf.d/10-user.conf && \
60 sudo $TEXTEDITOR /etc/systemd/user.conf.d/10-user.conf
70 function change_runlevel {
71 PS3="$SELECTTARGETMSG"
72 targets=("poweroff" "rescue" "multi-user" "graphical" "reboot" "cancel")
74 select pick in "${targets[@]}"
78 sudo systemctl isolate poweroff.target
82 sudo systemctl isolate reboot.target
86 sudo systemctl isolate rescue.target
90 sudo systemctl isolate multi-user.target
94 sudo systemctl isolate graphical.target
105 function enable_services {
107 OUTPUTITEM=$(systemctl list-unit-files | awk '/disabled/ {print $1}' | fzf -m -e --reverse)
108 if [ "$OUTPUTITEM" != "" ]
110 sudo systemctl enable $OUTPUTITEM
118 function start_services {
120 OUTPUTITEM=$(systemctl list-unit-files | awk '/disabled/ {print $1}' | fzf -m -e --reverse)
121 if [ "$OUTPUTITEM" != "" ]
123 sudo systemctl start $OUTPUTITEM
131 function stop_services {
133 OUTPUTITEM=$(systemctl list-unit-files | awk '/enabled/ {print $1}' | fzf -m -e --reverse)
134 if [ "$OUTPUTITEM" != "" ]
136 sudo systemctl stop $OUTPUTITEM
144 function disable_services {
146 OUTPUTITEM=$(systemctl list-unit-files | awk '/enabled/ {print $1}' | fzf -m -e --reverse)
147 if [ "$OUTPUTITEM" != "" ]
149 sudo systemctl disable $OUTPUTITEM
161 echo -e " ::Init menu:: "
162 echo -e " ┌─────────────────────────────────────────────────────────────┐"
163 echo -e " │ 1 Enable services 2 Disable services │"
164 echo -e " │ 3 Start services 4 Stop Services │"
165 echo -e " │ 5 List active services 6 Show boot messages │"
166 echo -e " │ 7 Edit configuration files 8 Change runlevel │"
167 echo -e " │ 9 Analyze boot │"
168 echo -e " └─────────────────────────────────────────────────────────────┘"
169 echo -e " Select an item - 0 Exit "
177 if [ $STATUSVAR -eq 0 ]; then
178 echo -e "$SERVICEPREFIXMSG$OUTPUTITEM$SERVICEENABLEDMSG"
188 if [ $STATUSVAR -eq 0 ]; then
189 echo -e "$SERVICEPREFIXMSG$OUTPUTITEM$SERVICEDISABLEDMSG"
199 if [ $STATUSVAR -eq 0 ]; then
200 echo -e "$SERVICEPREFIXMSG$OUTPUTITEM$SERVICESTARTEDMSG"
210 if [ $STATUSVAR -eq 0 ]; then
211 echo -e "$SERVICEPREFIXMSG$OUTPUTITEM$SERVICESTOPPEDMSG"
242 systemd-analyze blame
250 echo -e "$ERRORMSG$TRYAGAINMSG"