tazpanel annotate boot.cgi @ rev 92

pkgs.cgi: add block/unblock buttons
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Apr 14 17:48:18 2011 +0200 (2011-04-14)
parents 25602bc63ca7
children 0b4950af683b
rev   line source
pankso@50 1 #!/bin/sh
pankso@50 2 #
paul@82 3 # Boot CGI script - All what happens before login (grub, rcS, slim)
pankso@50 4 #
pankso@50 5 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v3
pankso@50 6 #
pankso@50 7
pankso@50 8 # Common functions from libtazpanel and source main boot config file.
pankso@50 9 . lib/libtazpanel
pankso@50 10 . /etc/rcS.conf
pascal@81 11 header
pankso@50 12 get_config
pankso@50 13
pankso@50 14 # Include gettext helper script.
pankso@50 15 . /usr/bin/gettext.sh
pankso@50 16
pankso@50 17 # Export package name for gettext.
pankso@50 18 TEXTDOMAIN='tazpanel'
pankso@50 19 export TEXTDOMAIN
pankso@50 20
pankso@50 21 TITLE="- Hardware"
pankso@50 22
pankso@50 23 #
pankso@50 24 # Commands
pankso@50 25 #
pankso@50 26
pascal@81 27 case " $(GET) " in
pascal@81 28 *\ daemons\ *)
pankso@51 29 #
pankso@51 30 # Everything until user login
pankso@51 31 #
paul@52 32 # Start and stop a daemon. I think we dont need restart since 2
paul@52 33 # clicks and you are done
pascal@81 34 daemon=$(GET daemons)
pascal@81 35 case "$daemon" in
pascal@81 36 start=*)
pankso@51 37 sleep 1
pascal@81 38 /etc/init.d/${daemon#start=} start | log ;;
pascal@81 39 stop=*)
pascal@81 40 /etc/init.d/${daemon#stop=} stop | log ;;
pankso@51 41 esac
pankso@51 42 . /etc/rcS.conf
pankso@51 43 TITLE="- Boot"
pankso@51 44 xhtml_header
pankso@67 45
pankso@51 46 cat << EOT
pankso@51 47 <div id="wrapper">
paul@52 48 <h2>`gettext "Manage daemons"`</h2>
pankso@51 49 <p>
paul@52 50 `gettext "Check, start and stop daemons on SliTaz"`
pankso@51 51 </p>
pankso@51 52 </div>
pankso@51 53 EOT
pankso@51 54 # Demon list
pankso@51 55 table_start
pankso@51 56 cat << EOT
pankso@51 57 <thead>
pankso@51 58 <tr>
pankso@51 59 <td>`gettext "Name"`</td>
pankso@51 60 <td>`gettext "Description"`</td>
pankso@51 61 <td>`gettext "Status"`</td>
pankso@51 62 <td>`gettext "Action"`</td>
pankso@51 63 <td>`gettext "PID"`</td>
pankso@51 64 </tr>
pankso@51 65 </thead>
pankso@51 66 EOT
pankso@51 67 cd /etc/init.d
pankso@51 68 list="`ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d \
pankso@51 69 -e /firewall/d`"
pankso@51 70 for name in $list
pankso@51 71 do
pankso@51 72 pkg=""
pankso@51 73 pid=""
pankso@51 74 status=""
pankso@51 75 SHORT_DESC=""
pankso@51 76 echo '<tr>'
pankso@51 77 # Name
pankso@51 78 echo "<td>$name</td>"
paul@52 79 # First check if daemon is started at bootime
pankso@51 80 [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot"
paul@52 81 # Standard SliTaz busybox daemons and firewall
pankso@51 82 case "$name" in
pankso@51 83 firewall)
pankso@51 84 gettext "<td>SliTaz Firewall with iptable rules</td>" ;;
pankso@51 85 httpd)
pankso@51 86 gettext "<td>Small and fast web server with CGI support</td>" ;;
pankso@51 87 ntpd)
paul@52 88 gettext "<td>Network time protocol daemon</td>" ;;
pankso@51 89 ftpd)
pankso@51 90 gettext "<td>Anonymous FTP server</td>" ;;
pankso@51 91 udhcpd)
pankso@51 92 gettext "<td>Busybox DHCP server</td>" ;;
pankso@51 93 syslogd|klogd)
pankso@51 94 gettext "<td>Linux Kernel log daemon</td>" ;;
pankso@76 95 crond)
pankso@76 96 gettext "<td>Execute scheduled commands</td>" ;;
pankso@76 97 dnsd)
pankso@76 98 gettext "<td>Small static DNS server daemon</td>" ;;
pankso@76 99 tftpd)
pankso@76 100 gettext "<td>Transfer a file on tftp request</td>" ;;
pankso@76 101 inetd)
pankso@76 102 gettext "<td>Listen for network connections and launch programs</td>" ;;
pankso@76 103 zcip)
pankso@76 104 gettext "<td>Manage a ZeroConf IPv4 link-local address</td>" ;;
pankso@51 105 *)
pankso@51 106 # Descrition from receipt
pankso@51 107 [ -d "$LOCALSTATE/installed/$name" ] && pkg=$name
pankso@51 108 [ -d "$LOCALSTATE/installed/${name%d}" ] && pkg=${name%d}
pankso@51 109 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam
pankso@51 110 if [ "$pkg" ]; then
pankso@51 111 . $LOCALSTATE/installed/$pkg/receipt
pankso@51 112 echo "<td>$SHORT_DESC</td>"
pankso@51 113 else
pankso@51 114 echo "<td>----</td>"
pankso@51 115 fi ;;
pankso@51 116 esac
pankso@51 117 # Attemp to get daemon status
pankso@51 118 pidfile=`find /var/run -name *$name*.pid`
pankso@51 119 [ "$pidfile" ] && pid=`cat $pidfile`
pankso@51 120 # dbus
pankso@51 121 [ -f /var/run/${name}/pid ] && pid=`cat /var/run/${name}/pid`
pankso@51 122 # apache
pankso@51 123 [ "$name" = "apache" ] && pid=`cat /var/run/$name/httpd.pid`
pankso@51 124 # Pidof works for many daemon
pankso@51 125 [ "$pid" ] || pid=`pidof $name`
pankso@51 126 if [ "$pid" ]; then
pankso@51 127 echo "<td><img src='$IMAGES/started.png' /></td>"
pankso@51 128 echo "<td><a href='$SCRIPT_NAME?daemons=stop=$name'>
pankso@51 129 <img src='$IMAGES/stop.png' /></a></td>"
pankso@51 130 echo "<td>$pid</td>"
pankso@51 131 else
pankso@51 132 echo "<td>-</td>"
pankso@51 133 echo "<td><a href='$SCRIPT_NAME?daemons=start=$name'>
pankso@51 134 <img src='$IMAGES/start.png' /></a></td>"
pankso@51 135 echo "<td>-----</td>"
pankso@51 136 fi
pankso@51 137 echo '</tr>'
pankso@51 138 done
pankso@51 139 table_end ;;
pankso@50 140 *)
pankso@50 141 #
pankso@51 142 # Default content with summary
pankso@50 143 #
pankso@50 144 . /etc/rcS.conf
pankso@50 145 TITLE="- Boot"
pankso@50 146 xhtml_header
pankso@67 147
pankso@50 148 cat << EOT
pankso@50 149 <div id="wrapper">
pankso@51 150 <h2>`gettext "Boot &amp; Start services"`</h2>
pankso@50 151 <p>
paul@82 152 `gettext "Everything that happens before user login"`
pankso@50 153 </p>
pankso@50 154 </div>
pankso@51 155 <div>
pankso@51 156 <a class="button" href="$SCRIPT_NAME?daemons">Manage daemons</a>
pankso@51 157 </div>
pankso@51 158
pankso@57 159 <h3>`gettext "Configuration files"`</h3>
pankso@57 160 <ul>
pankso@57 161 <li>`gettext "Main configuration file:"`
pankso@57 162 <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li>
pankso@57 163 <li>`gettext "Grub menu:"`
pankso@57 164 <a href="index.cgi?file=/boot/grub/menu.lst">menu.lst</a></li>
pankso@57 165 <li>`gettext "Login manager settings:"`
pankso@57 166 <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li>
pankso@73 167 </ul>
pankso@57 168
pankso@50 169 <h3>`gettext "Kernel cmdline"`</h3>
pankso@50 170 <pre>
pankso@50 171 `cat /proc/cmdline`
pankso@50 172 </pre>
pankso@50 173 <h3>`gettext "Local startup commands"`</h3>
pankso@50 174 <pre>
pankso@75 175 $(cat /etc/init.d/local.sh | syntax_highlighter sh)
pankso@50 176 </pre>
pankso@50 177 EOT
pankso@50 178 ;;
pankso@50 179 esac
pankso@50 180
pankso@50 181 xhtml_footer
pankso@50 182 exit 0