Subversion Repositories livecd

Rev

Rev 129 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 129 Rev 133
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
# Urs Beyerle, PSI
3
# Urs Beyerle, PSI
4
#
4
#
5
 
5
 
6
### dialog or xdialog?
6
### dialog or xdialog?
7
DIALOG="dialog"
7
DIALOG="dialog"
8
XDIALOG_HIGH_DIALOG_COMPAT=1
8
XDIALOG_HIGH_DIALOG_COMPAT=1
9
export XDIALOG_HIGH_DIALOG_COMPAT
9
export XDIALOG_HIGH_DIALOG_COMPAT
10
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
10
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
11
 
11
 
12
### definitions 
12
### definitions 
13
TITLE="PSI Menu"
13
TITLE="PSI Menu"
14
MENU_TITLE="PSI Menu"
14
MENU_TITLE="PSI Menu"
15
 
15
 
16
MENU_1="Xterm"
16
MENU_1="Xterm"
17
EXEC_1="xterm"
17
EXEC_1="xterm"
18
 
18
 
19
MENU_2="Web Browser (firefox)"
19
MENU_2="Web Browser (firefox)"
20
EXEC_2="firefox"
20
EXEC_2="firefox"
21
 
21
 
22
MENU_3="NX Client (connect to LLCs)"
22
MENU_3="NX Client (connect to LLCs)"
23
EXEC_3="nxclient"
23
EXEC_3="nxclient"
24
 
24
 
25
MENU_4="Windows Terminal Server"
25
MENU_4="Windows Terminal Server"
26
EXEC_4="rdesktop $RDESKTOP_OPT -d PSICH -u win_username -a 24 -x lan -r sound:local winterm1"
26
EXEC_4="rdesktop $RDESKTOP_OPT -d PSICH -u win_username -a 24 -x lan -r sound:local winterm1"
27
 
27
 
28
MENU_5="Windows Terminal Server (full screen)"
28
MENU_5="Windows Terminal Server (full screen)"
29
EXEC_5="rdesktop $RDESKTOP_OPT -d PSICH -f -u win_username -a 24 -x lan -r sound:local winterm1"
29
EXEC_5="rdesktop $RDESKTOP_OPT -d PSICH -f -u win_username -a 24 -x lan -r sound:local winterm1"
30
 
30
 
31
MENU_6="Hardisk Partition Tool (gparted)"
31
MENU_6="Hardisk Partition Tool (gparted)"
32
EXEC_6="gparted"
32
EXEC_6="gparted"
33
 
33
 
34
MENU_7="Change Keyboard Layout"
34
MENU_7="Change Keyboard Layout"
35
EXEC_7="sudo system-config-keyboard"
35
EXEC_7="sudo system-config-keyboard"
36
 
36
 
37
MENU_8="Configure Display"
37
MENU_8="Configure Display"
38
EXEC_8="sudo psi-config-display"
38
EXEC_8="sudo psi-config-display"
39
 
39
 
40
MENU_9="Configure Soundcard"
40
MENU_9="Configure Soundcard"
41
EXEC_9="sudo psi-config-soundcard"
41
EXEC_9="sudo system-config-soundcard"
42
 
42
 
43
MENU_x="Restart X-Server (will kill all your jobs)"
43
MENU_x="Restart X-Server (will kill all your jobs)"
44
MENU_down="Reboot/Shutdown"
44
MENU_down="Reboot/Shutdown"
45
MENU_quit="Quit"
45
MENU_quit="Quit"
46
 
46
 
47
# tmpdir
47
# tmpdir
48
TMPDIR=/tmp/psi-menu.$$
48
TMPDIR=/tmp/psi-menu.$$
49
TMP=$TMPDIR/dialog
49
TMP=$TMPDIR/dialog
50
mkdir -p $TMPDIR
50
mkdir -p $TMPDIR
51
 
51
 
52
### functions
52
### functions
53
shutdown () 
53
shutdown () 
54
{
54
{
55
    $DIALOG --title "$TITLE" --radiolist "Reboot or shutdown the PC?" 0 0 3 poweroff "" on reboot "" off 2>$TMP
55
    $DIALOG --title "$TITLE" --radiolist "Reboot or shutdown the PC?" 0 0 3 poweroff "" on reboot "" off 2>$TMP
56
    ACTION=$(cat $TMP)
56
    ACTION=$(cat $TMP)
57
    if [ $ACTION ]; then
57
    if [ $ACTION ]; then
58
	$ACTION
58
	$ACTION
59
	exit 1
59
	exit 1
60
    fi
60
    fi
61
}
61
}
62
 
62
 
63
# not really restart x, but will kill all processes of localuser
63
# not really restart x, but will kill all processes of localuser
64
# (including windwos manager and autologin)
64
# (including windwos manager and autologin)
65
restartx ()
65
restartx ()
66
{
66
{
67
    ps wwaux | grep "^l_psi" | awk '{ print $2 }' | while read pid; do kill -9 $pid; done    
67
    ps wwaux | grep "^l_psi" | awk '{ print $2 }' | while read pid; do kill -9 $pid; done    
68
}
68
}
69
 
69
 
70
### show menue
70
### show menue
71
while true; do
71
while true; do
72
    $DIALOG --title "$TITLE" \
72
    $DIALOG --title "$TITLE" \
73
	--menu "$MENU_TITLE" 0 0 12\
73
	--menu "$MENU_TITLE" 0 0 12\
74
	1 "$MENU_1"\
74
	1 "$MENU_1"\
75
	2 "$MENU_2"\
75
	2 "$MENU_2"\
76
	3 "$MENU_3" \
76
	3 "$MENU_3" \
77
	4 "$MENU_4" \
77
	4 "$MENU_4" \
78
	5 "$MENU_5" \
78
	5 "$MENU_5" \
79
	6 "$MENU_6" \
79
	6 "$MENU_6" \
80
	7 "$MENU_7" \
80
	7 "$MENU_7" \
81
	8 "$MENU_8" \
81
	8 "$MENU_8" \
82
	9 "$MENU_9" \
82
	9 "$MENU_9" \
83
	10 "$MENU_x" \
83
	10 "$MENU_x" \
84
	11 "$MENU_down" \
84
	11 "$MENU_down" \
85
	12 "$MENU_quit" \
85
	12 "$MENU_quit" \
86
	2> $TMP
86
	2> $TMP
87
 
87
 
88
    [ $? -ne 0 ] && break
88
    [ $? -ne 0 ] && break
89
 
89
 
90
    CHOICE=$(cat $TMP)
90
    CHOICE=$(cat $TMP)
91
 
91
 
92
    case "$CHOICE" in
92
    case "$CHOICE" in
93
     1)
93
     1)
94
      (sleep 0.5; $EXEC_1) &
94
      (sleep 0.5; $EXEC_1) &
95
      ;;
95
      ;;
96
     2)
96
     2)
97
      (sleep 0.5; $EXEC_2) &
97
      (sleep 0.5; $EXEC_2) &
98
      ;;
98
      ;;
99
     3)
99
     3)
100
      (sleep 0.5; $EXEC_3) &
100
      (sleep 0.5; $EXEC_3) &
101
      ;;
101
      ;;
102
     4)
102
     4)
103
      (sleep 0.5; $EXEC_4) &
103
      (sleep 0.5; $EXEC_4) &
104
      ;;
104
      ;;
105
     5)
105
     5)
106
      (sleep 0.5; $EXEC_5) &
106
      (sleep 0.5; $EXEC_5) &
107
      ;;
107
      ;;
108
     6)
108
     6)
109
      (sleep 0.5; $EXEC_6) &
109
      (sleep 0.5; $EXEC_6) &
110
      ;;
110
      ;;
111
     7)
111
     7)
112
      (sleep 0.5; $EXEC_7) &
112
      (sleep 0.5; $EXEC_7) &
113
      ;;
113
      ;;
114
     8)
114
     8)
115
      (sleep 0.5; $EXEC_8) &
115
      (sleep 0.5; $EXEC_8) &
116
      ;;
116
      ;;
117
     9)
117
     9)
118
      (sleep 0.5; $EXEC_9) &
118
      (sleep 0.5; $EXEC_9) &
119
      ;;
119
      ;;
120
     10)
120
     10)
121
      restartx
121
      restartx
122
      ;;
122
      ;;
123
     11)
123
     11)
124
      shutdown || break
124
      shutdown || break
125
      ;;
125
      ;;
126
     12)
126
     12)
127
      break
127
      break
128
      ;;
128
      ;;
129
    esac
129
    esac
130
done
130
done