tazpanel annotate settings.cgi @ rev 292

translatable header, footer & titles; make pot
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Apr 11 20:12:41 2012 +0300 (2012-04-11)
parents f94970922f85
children fdfc6b494539
rev   line source
pankso@42 1 #!/bin/sh
pankso@42 2 #
pankso@42 3 # System settings CGI interface: user, locale, keyboard, date. Since we
paul@205 4 # don't have multiple pages here there is only one case used to get command
paul@205 5 # values and the full content is followed directly.
pankso@42 6 #
pankso@112 7 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License
pankso@42 8 #
pankso@42 9
pankso@42 10 # Common functions from libtazpanel
pankso@42 11 . lib/libtazpanel
pankso@42 12 get_config
pascal@81 13 header
pankso@42 14
al@292 15 TITLE=$(gettext 'TazPanel - Settings')
pankso@42 16
pankso@42 17 #
pankso@42 18 # Commands executed before page loading.
pankso@42 19 #
pankso@42 20
pascal@81 21 case " $(GET) " in
pascal@115 22 *\ do\ *)
paul@205 23 # Assume no array support in httpd_helper.sh ;^)
pascal@115 24 users=""
pascal@115 25 IFS="&"
pascal@115 26 for i in $QUERY_STRING ; do
pascal@115 27 case "$i" in
pascal@115 28 user=*) users="$users ${i#user=}" ;;
pascal@115 29 esac
pascal@115 30 done
pascal@115 31 unset IFS
pascal@115 32 for cmd in "Delete user" "Lock user" "Unlock user" \
pascal@115 33 "Change password" ; do
pascal@115 34 [ "$(GET do)" == "$(gettext "$cmd")" ] || continue
pascal@115 35 for user in $users ; do
pascal@115 36 case "$cmd" in
pascal@115 37 Delete*) deluser $user ;;
pankso@119 38 Lock*) passwd -l $user | log ;;
pankso@119 39 Unlock*) passwd -u $user | log ;;
pascal@252 40 Change*) echo "$user:$(GET password)" | chpasswd -m | log ;;
pascal@115 41 esac
pascal@115 42 done
pascal@115 43 done ;;
pascal@115 44 *\ adduser\ *)
pankso@42 45 #
pankso@42 46 # Manage system user accounts
pankso@42 47 #
pascal@81 48 user=$(GET adduser)
pascal@115 49 passwd=$(GET passwd)
pascal@81 50 if [ -n "$user" ]; then
slaxemulator@233 51 adduser -D -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user
pascal@252 52 echo "$user:$passwd" | chpasswd -m | log
slaxemulator@233 53 for g in audio cdrom floppy video tty
pascal@81 54 do
pascal@81 55 addgroup $user $g
pascal@81 56 done
pascal@81 57 fi ;;
pascal@81 58 *\ gen_locale\ *)
pascal@81 59 new_locale=$(GET gen_locale) ;;
pascal@141 60 *\ gen_keymap\ *)
pascal@141 61 new_keymap=$(GET gen_keymap) ;;
pascal@142 62 *\ apply_xorg_kbd\ *)
pascal@142 63 sed -i "s/XkbLayout.*/XkbLayout \" \"$(GET apply_xorg_kbd)\"/" \
pascal@142 64 /etc/X11/xorg.conf.d/40-Keyboard.conf ;;
pascal@81 65 *\ rdate\ *)
pankso@42 66 rdate -s tick.greyware.com ;;
pascal@81 67 *\ hwclock\ *)
pankso@150 68 hwclock -w -u ;;
pankso@110 69 *\ panel_pass*)
pankso@110 70 sed -i s@/:root:.*@/:root:$(GET panel_pass)@ $HTTPD_CONF ;;
pankso@110 71 *\ style*)
pankso@110 72 sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG
al@292 73 . $CONFIG ;;
pankso@42 74 esac
pankso@42 75
pankso@42 76 #
pankso@42 77 # Default xHTML content
pankso@42 78 #
pankso@42 79 xhtml_header
pankso@67 80
pankso@110 81 case " $(GET) " in
pankso@110 82 *\ user*)
pankso@110 83 #
pankso@110 84 # Users management
pankso@110 85 #
pankso@110 86 cat <<EOT
pascal@115 87 <a name="users"></a>
pankso@110 88 <h3>`gettext "Manage users"`</h3>
pankso@110 89 <form method="get" action="$SCRIPT_NAME">
pascal@115 90 <div id="actions">
pascal@115 91 <div class="float-left">
pascal@115 92 $(gettext "Selection:")
pascal@115 93 <input type="submit" name="do" value="`gettext "Delete user"`" />
pascal@115 94 <input type="submit" name="do" value="`gettext "Lock user"`" />
pascal@115 95 <input type="submit" name="do" value="`gettext "Unlock user"`" />
pascal@115 96 </div>
pascal@115 97 </div>
pankso@42 98 EOT
pascal@115 99 table_start
pascal@115 100 cat << EOT
pascal@115 101 <tr class="thead">
pascal@115 102 <td>`gettext "Login"`</td>
pascal@115 103 <td>`gettext "User ID"`</td>
pascal@115 104 <td>`gettext "Name"`</td>
pascal@115 105 <td>`gettext "Home"`</td>
pascal@115 106 <td>`gettext "Shell"`</td>
pascal@115 107 </tr>
pascal@115 108 EOT
pascal@115 109 for login in `cat /etc/passwd | cut -d ":" -f 1`
pankso@110 110 do
pascal@115 111 if [ -d /home/$login ]; then
pascal@115 112 colorlogin=$login
pascal@115 113 grep -qs "^$login:!" /etc/shadow &&
pascal@115 114 colorlogin="<span style='color: red;'>$login</span>"
pascal@115 115 IFS=':'
pascal@115 116 set -- $(grep "^$login:" /etc/passwd)
pascal@115 117 unset IFS
pascal@115 118 uid=$3
pascal@115 119 gid=$4
pascal@115 120 name="$(echo $5 | sed s/,.*//)"
pascal@115 121 home="$6"
pascal@115 122 shell=$7
pascal@115 123 cat <<EOT
pascal@115 124 <tr>
pascal@115 125 <td><input type='checkbox' name='user' value='$login' />
pascal@115 126 <img src='$IMAGES/user.png' />$colorlogin</td>
pascal@115 127 <td>$uid:$gid</td>
pascal@115 128 <td>$name</td>
pascal@115 129 <td>$home</td>
pascal@115 130 <td>$shell</td>
pascal@115 131 </tr>
pascal@115 132 EOT
pankso@110 133 fi
pankso@110 134 done
pankso@110 135 table_end
pankso@110 136 cat << EOT
pankso@117 137 <p>
pankso@117 138 $(gettext "Password":)
pascal@121 139 <input type="password" name="password" />
pankso@117 140 <input type="submit" name="do" value="`gettext "Change password"`" />
pankso@117 141 </p>
pankso@42 142 </form>
pankso@42 143
pankso@42 144 <h4>`gettext "Add a new user"`</h4>
pankso@42 145 <form method="get" action="$SCRIPT_NAME">
pankso@42 146 <input type="hidden" name="user" />
pankso@42 147 <p>`gettext "User login:"`</p>
pankso@42 148 <p><input type="text" name="adduser" size="30" /></p>
pankso@42 149 <p>`gettext "User password:"`</p>
pankso@42 150 <p><input type="password" name="passwd" size="30" /></p>
pankso@42 151 <input type="submit" value="`gettext "Create user"`" />
pankso@42 152 </form>
pascal@147 153
pascal@147 154 <h4>`gettext "Current user sessions"`</h4>
pascal@147 155 <pre>
pascal@147 156 $(who)
pascal@147 157 </pre>
pascal@147 158
pascal@147 159 <h4>`gettext "Last user sessions"`</h4>
pascal@147 160 <pre>
pascal@147 161 $(last)
pascal@147 162 </pre>
pankso@42 163 EOT
pankso@110 164 ;;
pankso@110 165 *)
pankso@110 166 #
pankso@110 167 # Defaut system settings page
pankso@110 168 #
pankso@110 169 cat << EOT
pankso@110 170 <div id="wrapper">
pankso@110 171 <h2>$(gettext "System settings")</h2>
pankso@110 172 <p>$(gettext "Manage system time, users or language settings")<p>
pankso@110 173 </div>
pankso@110 174 <div id="actions">
pankso@110 175 <a class="button" href="$SCRIPT_NAME?users">
pankso@110 176 <img src="$IMAGES/users.png" />$(gettext "Manage users")</a>
pankso@110 177 </div>
pankso@42 178
pankso@110 179 <h3>`gettext "System time"`</h3>
pankso@110 180 <pre>
pankso@110 181 `gettext "Time zome :"` `cat /etc/TZ`
pankso@110 182 `gettext "System time :"` `date`
pankso@110 183 `gettext "Hardware clock :"` `hwclock -r`
pankso@110 184 </pre>
pankso@110 185 <a class="button" href="$SCRIPT_NAME?rdate">`gettext "Sync online"`</a>
pankso@110 186 <a class="button" href="$SCRIPT_NAME?hwclock">`gettext "Set hardware clock"`</a>
pankso@110 187 EOT
pankso@110 188 #
pankso@110 189 # Locale settings
pankso@110 190 #
pankso@110 191 cat << EOT
pankso@42 192 <a name="locale"></a>
pankso@42 193 <h3>`gettext "System language"`</h3>
pankso@42 194 <p>
pankso@42 195 EOT
pankso@42 196 # Check if a new locale was requested
pankso@42 197 if [ -n "$new_locale" ]; then
pankso@42 198 rm -rf /usr/lib/locale/$new_locale
pankso@42 199 localedef -i $new_locale -c -f UTF-8 \
pankso@42 200 /usr/lib/locale/$new_locale
pankso@42 201 # System configuration
pankso@42 202 echo "LANG=$new_locale" > /etc/locale.conf
pankso@42 203 echo "LC_ALL=$new_locale" >> /etc/locale.conf
paul@52 204 eval_gettext "You must logout and login again to your current
pankso@42 205 session to use \$new_locale locale."
pankso@42 206 else
pankso@110 207 gettext "Current system locales: "
pankso@42 208 locale -a
pankso@42 209 fi
pankso@42 210 cat << EOT
pankso@42 211 </p>
pankso@42 212 <form method="get" action="$SCRIPT_NAME">
pankso@110 213 $(gettext "Available locales:")
pascal@81 214 <select name="gen_locale">
pankso@42 215 <option value="en_US">en_US</options>
pankso@110 216 $(list_locales)
pankso@42 217 </select>
pankso@110 218 <input type="submit" value="$(gettext "Activate")" />
pankso@42 219 </form>
pankso@110 220
pascal@141 221 <a name="keymap"></a>
pascal@141 222 <h3>`gettext "Console keymap"`</h3>
pascal@141 223 <p>
pascal@141 224 EOT
pascal@141 225 # Check if a new keymap was requested
pascal@141 226 if [ -n "$new_keymap" ]; then
pascal@141 227 echo "$new_keymap" > /etc/keymap.conf
pascal@141 228 if [ -x /bin/loadkeys ]; then
pascal@141 229 loadkeys $new_keymap
pascal@141 230 else
pascal@141 231 loadkmap < /usr/share/kmap/$new_keymap.kmap
pascal@141 232 fi
pascal@141 233 fi
pascal@141 234 gettext "Current console keymap: "
pascal@142 235 keymap=$(cat /etc/keymap.conf)
pascal@142 236 echo $keymap
pascal@142 237 echo "</p>"
pascal@142 238 if [ -n "$keymap" ]; then
pascal@142 239 case "$keymap" in
pascal@142 240 fr_CH*)
pascal@142 241 keymap="ch" ;;
pascal@142 242 ru)
pascal@142 243 keymap="us,ru(winkeys)" ;;
pascal@142 244 slovene)
pascal@142 245 keymap=si ;;
pascal@142 246 *)
pascal@142 247 keymap=${keymap%-lat*}
pascal@142 248 keymap=${keymap%-abnt2} ;;
pascal@142 249 esac
pascal@142 250 keyboard_config=/etc/X11/xorg.conf.d/40-Keyboard.conf
pascal@142 251 cat << EOT
pascal@142 252 <form method="get" action="$SCRIPT_NAME">
pascal@142 253 $(gettext "Suggested keymap for Xorg:")
pascal@142 254 <input type="submit" name "apply_xorg_kbd" value="$keymap" />
pascal@142 255 <a class="button" href="index.cgi?file=$keyboard_config">
pascal@142 256 <img src="$IMAGES/edit.png" />$(gettext "Edit")</a>
pascal@142 257 </form>
pascal@142 258 EOT
pascal@142 259 fi
pascal@141 260 cat << EOT
pascal@141 261 <form method="get" action="$SCRIPT_NAME">
pascal@141 262 $(gettext "Available keymaps:")
pascal@141 263 <select name="gen_keymap">
pascal@141 264 $(list_keymaps)
pascal@141 265 </select>
pascal@141 266 <input type="submit" value="$(gettext "Activate")" />
pascal@141 267 </form>
pascal@141 268
pankso@193 269 <h2>$(gettext "Panel configuration")</h2>
pankso@110 270 <form method="get" action="$SCRIPT_NAME">
pankso@110 271 <p>
pankso@110 272 $(gettext "Style:")
pankso@110 273 <select name="style">
pankso@110 274 $(list_styles)
pankso@110 275 </select>
pankso@110 276 <input type="submit" value="$(gettext "Activate")" />
pankso@110 277 </p>
pankso@110 278 </form>
pankso@110 279 <form method="get" action="$SCRIPT_NAME">
pankso@110 280 <p>
pankso@110 281 $(gettext "Panel password:")
pankso@110 282 <input type="password" name="panel_pass"/>
pankso@110 283 <input type="submit" value="$(gettext "Change")" />
pankso@110 284 </p>
pankso@110 285 </form>
pankso@110 286 <p>
pankso@110 287 $(gettext "Configuration files: ")
pankso@110 288 <a class="button" href="index.cgi?file=$CONFIG">
pankso@110 289 <img src="$IMAGES/edit.png" />$(gettext "Panel")</a>
pankso@110 290 <a class="button" href="index.cgi?file=$HTTPD_CONF">
pankso@110 291 <img src="$IMAGES/edit.png" />$(gettext "Server")</a>
pankso@110 292 </p>
pankso@110 293 <p>
pankso@110 294 $(gettext "TazPanel provides a debuging mode and page:")
pankso@110 295 <a href='/index.cgi?debug'>debug</a>
pankso@110 296 </p>
pankso@42 297 EOT
pankso@110 298 ;;
pankso@110 299 esac
pankso@42 300
pankso@42 301 xhtml_footer
pankso@42 302 exit 0