grml-iptstate: check for '_conntrack' module instead of ip_conntrack, some formating...
[grml-scripts.git] / usr_sbin / grml-setservices
1 #!/bin/sh
2 # Filename:      grml-setservices
3 # Purpose:       interface for basic configuration of system startup
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Son Apr 15 10:57:18 CEST 2007 [mika]
8 ################################################################################
9
10 PN="$(basename $0)"
11 TMP=$(mktemp)
12 DIALOG=dialog
13 CONFFILE='/etc/runlevel.conf'
14
15 . /etc/grml/script-functions
16 . /etc/grml/lsb-functions
17
18 check4root || exit 100
19
20 bailout(){
21   rm -f "$TMP"
22   exit 0
23 }
24
25 trap bailout 1 2 3 15
26
27 is_value_set(){
28  [ -n "$1" ] || return 2
29  [ -r "$TMP" ] || return 3
30  grep -q "$1" $TMP && return 0 || return 1
31 }
32
33 INFO="Which services would you like to have enabled on your system?
34
35 Notice: this script will adjust your ${CONFFILE}, the
36 file which provides the startup configuration for your
37 system. You can edit the file manually as well.
38
39 If you do not know what to choose just take the defaults
40 or choose cancel.
41 "
42
43 # enable checks only if the according init script is present
44 [ -r /etc/init.d/mdadm ]  && SRAID='mdadm!software-raid via mdadm!on'
45 [ -r /etc/init.d/dmraid ] && MRAID='dmraid!software-raid via dmraid!off'
46 [ -r /etc/init.d/dbus -o -r /etc/init.d/dbus-1 ] && DBUS='dbus!hal/dbus (important for KDE e.g.)!off'
47
48 # adjust setup
49 set_values(){
50   if [ -n "$SRAID" ] ; then
51      if is_value_set "mdadm"  ; then
52         update-rc.d -f mdadm remove >/dev/null 2>&1
53         update-rc.d mdadm-raid start 25 S . start 50 0 6 . >/dev/null 2>&1
54         update-rc.d mdadm defaults 25 >/dev/null 2>&1
55      else
56         update-rc.d -f mdadm remove >/dev/null 2>&1
57         update-rc.d mdadm stop 20 0 1 6 . >/dev/null 2>&1
58         update-rc.d -f mdadm-raid remove >/dev/null 2>&1
59         update-rc.d mdadm-raid stop 20 0 1 6 . >/dev/null 2>&1
60      fi
61   fi
62
63   if [ -n "$MRAID" ] ; then
64      if is_value_set "dmraid" ; then
65         update-rc.d -f dmraid remove >/dev/null 2>&1
66         update-rc.d dmraid start 04 S . start 51 0 6 . >/dev/null
67      else
68         update-rc.d -f dmraid remove >/dev/null 2>&1
69         update-rc.d dmraid stop 20 0 1 6 . >/dev/null 2>&1
70      fi
71   fi
72
73   if [ -n "$DBUS" ] ; then
74      if is_value_set "dbus" ; then
75         update-rc.d -f dbus remove >/dev/null 2>&1
76         update-rc.d dbus defaults >/dev/null 2>&1
77      else
78         update-rc.d -f dbus remove >/dev/null 2>&1
79         update-rc.d dbus stop 20 0 1 6 . >/dev/null 2>&1
80      fi
81   fi
82 }
83
84 # the interface itself
85 oifs="$IFS"
86 IFS='!'
87 $DIALOG --title "$PN" --checklist "$INFO" 30 65 8 $SRAID $MRAID $DBUS 2>$TMP
88
89 retval="$?"
90 case $retval in
91     (0)   set_values ;;
92     (1)   echo "Cancel pressed." ; exit 1 ;;
93     (255) echo "ESC pressed."    ; exit 1 ;;
94 esac
95
96 retval=$?
97 case $retval in
98     (0)
99           $DIALOG --title "$PN" --stdout --msgbox "Adjusting system runlevel configuration via $CONFFILE was successful." 0 0
100           esyslog user.notice "$PN" "Writing language settings ($LANGUAGE) to $CONFFILE was successful."
101           ;;
102     *)
103           $DIALOG --title "$PN" --stdout --msgbox "Error writing settings to ${CONFFILE}." 0 0
104           esyslog user.notice "$PN" "Error writing settings to ${CONFFILE}."
105           ;;
106 esac
107
108 rm -f $TMP
109 IFS="$oifs"
110
111 ## END OF FILE #################################################################
112 # vim: ai tw=80 expandtab