tazpanel view tazpanel @ rev 531

index.cgi: add renice support (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 28 14:03:48 2015 +0200 (2015-08-28)
parents f8e0ae0ac1d9
children 082b622cb781
line source
1 #!/bin/sh
2 #
3 # Tiny Tazpanel cmdline interface
4 #
5 # Copyright (C) 2012-2015 SliTaz GNU/Linux - BSD License
6 #
8 VERSION=522
11 # Get the configuration file and functions
13 CONFIG="/etc/slitaz/tazpanel.conf"
14 [ -f "$CONFIG" ] && . $CONFIG
15 [ -f "data/tazpanel.conf" ] && . data/tazpanel.conf
16 [ ! "$PANEL" ] && echo "No config file found: $CONFIG" && exit 1
18 . /lib/libtaz.sh
21 # I18n
23 TEXTDOMAIN='tazpanel'
24 export TEXTDOMAIN
27 #
28 # Commands
29 #
31 NAME=tazpanel
32 DESC="SliTaz administration and configuration panel."
33 DAEMON=/usr/sbin/httpd
34 PIDFILE=/run/$NAME.pid
36 case "$1" in
37 -h|*help|*usage)
38 cat <<EOT
39 Usage: tazpanel [command]
41 Commands:
42 start Start tazpanel daemon
43 stop Stop tazpanel daemon
44 restart Restart tazpanel daemon
45 <app> Open TazPanel page in the browser, where <app> is one of:
46 boot, hardware, help, index, installer, live, network, settings, pkgs
47 If <app> is empty, index page will open in the browser.
48 You can also open sub-pages, so "pkgs#list" will open packages list.
50 EOT
51 ;;
52 start)
53 if [ -f $PIDFILE ]; then
54 _ 'TazPanel is already running.'
55 exit 1
56 fi
57 _n 'Starting TazPanel web server on port %d...' $HTTPD_PORT
58 httpd -p $HTTPD_PORT -u root -c $HTTPD_CONF \
59 -r "$(_ 'TazPanel Authentication - Default: root:root')" &
60 ps | grep "httpd -p $HTTPD_PORT " | grep -v grep | \
61 awk '{ print $1 }' > $PIDFILE
62 [ ! -f /var/lib/tazpkg/installed.info ] && tazpkg -l>/dev/null&
63 status ;;
64 stop)
65 if [ ! -f $PIDFILE ]; then
66 _ 'TazPanel is not running.'
67 exit 1
68 fi
69 _n 'Stopping TazPanel web server...'
70 kill $(pgrep -f TazPanel)
71 rm -f $PIDFILE
72 status ;;
73 restart)
74 tazpanel stop; sleep 1; tazpanel start;;
75 *)
76 . /etc/slitaz/applications.conf
77 USER_CONFIG="$HOME/.config/slitaz/applications.conf"
78 [ -f "$USER_CONFIG" ] && . $USER_CONFIG
80 applet=${1:-index}
81 case $1 in
82 *#*) url="http://127.0.0.1:82/${applet%%#*}.cgi?${applet#*#}&guiuser=$(id -un)";;
83 *) url="http://127.0.0.1:82/$applet.cgi?guiuser=$(id -un)";;
84 esac
85 echo "$url"
87 case "$BROWSER" in
88 tazweb) tazweb --notoolbar "$url" & ;;
89 midori) midori "--app=$url" & ;;
90 *) $BROWSER "$url" & ;;
91 esac ;;
92 esac
94 exit 0