-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautostart
executable file
·85 lines (68 loc) · 2.03 KB
/
autostart
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Skript zum einfachen ein/ausschalten des Autostarts in der start.conf
# [email protected] April 2013
#
#
# usage: autostart GRUPPE LABEL [on/off]
#
# Der betroffene Autostart braucht ein Hilfslabel am Ende der Zeile:
# Bsp:
# Autostart = no # ubuntu12
# Wird ON/OFF weggelassen, schaltet das Skript den Status einfach um.
# Konfiguration
LINBOPFAD=/var/linbo
PREFIX=start.conf
# Parameter in Variablen speichern, dabei den Linbo-Pfad automatisch ergänzen.
STARTCONF=$LINBOPFAD/$PREFIX.$1
LABEL=$2
# offensichtliche Bedienfehler abfangen
# Startkonfiguration existiert nicht:
if [ ! -e $STARTCONF ]
then
echo $STARTCONF existiert nicht... Abbruch >&2
exit 1
fi
# Label nicht vorhanden oder mehrdeutig
UNIQUE=$(grep "$LABEL" "$STARTCONF" | grep -c "utostart")
if [ "$UNIQUE" != "1" ]
then
echo Label nicht vorhanden, nicht eindeutig oder nicht in einer Autostart-Zeile... >&2
echo 'USAGE: autostart <GRUPPE> <LABEL> <yes|no|status>'
exit 1
fi
case "$3" in
[oO][nN])
SWITCH=ON
;;
[oO][fF][fF])
SWITCH=OFF
;;
[sS][tT][aA][tT][uU][sS])
STATUSQUO=$(grep "$LABEL" "$STARTCONF" |grep utostart | cut -d" " -f3)
echo -e "Autostart in $STARTCONF ist jetzt: $STATUSQUO"
exit 0
;;
*)
STATUSQUO=$(grep "$LABEL" "$STARTCONF" |grep utostart | cut -d" " -f3)
[[ "$STATUSQUO" == "yes" ]] && SWITCH=OFF || SWITCH=ON
;;
esac
# Zeile aus start.conf extrahieren
OLDLINE=$(grep "$LABEL" "$STARTCONF")
case "$SWITCH" in
OFF)
echo -e "Autostart \e[00;31mausschalten\e[00m"...
NEWLINE=$(echo $OLDLINE | sed -e 's/[yY][eE][sS]/no/g')
;;
ON)
echo -e "Autostart \e[00;32meinschalten\e[00m"...
NEWLINE=$(echo $OLDLINE | sed -e 's/[nN][oO]/yes/g')
;;
*)
echo "Irgendwas ist schief gelaufen, diese Zeile hätte nie ausgeführt werden dürfen..." >&2
exit 1
;;
esac
sed -e "s/$OLDLINE/$NEWLINE/g" -i $STARTCONF
STATUSQUO=$(grep "$LABEL" "$STARTCONF" |grep utostart | cut -d" " -f3)
echo -e "Autostart in $STARTCONF ist jetzt: $STATUSQUO"