tazpanel view tazpanel @ rev 524

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