Index: branches/buildroot-ng/openwrt/package/base-files/default/sbin/rcconf
===================================================================
--- branches/buildroot-ng/openwrt/package/base-files/default/sbin/rcconf (revision 0)
+++ branches/buildroot-ng/openwrt/package/base-files/default/sbin/rcconf (revision 0)
@@ -0,0 +1,208 @@
+#!/bin/sh
+#
+# Copyright (C) 2006 OpenWrt.org - Florian Fainelli <florian@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: $
+#
+#
+# Global definitions
+
+INIT_PATH="${1:-/etc/init.d}"
+VERSION=0.1
+PROTECTED_SERVICES="nvram boot network done"
+
+# This function stores the proctected servies, a wrapper to a shell configuration file or
+# something else can be added in the future, it just works now
+
+get_protected_services()
+{
+ echo "$PROTECTED_SERVICES"
+}
+
+# This function checks if a service is protected
+# returns 1 in case it is
+# returns 0 in cast it is not
+
+is_protected_service()
+{
+ if [ $(echo $(get_protected_services "") | grep -c "$1") -ge 1 ]; then
+ echo 1
+ else
+ echo 0
+ fi
+}
+
+# This function lists the active services that match the rcS syntax
+# and that are executables
+
+get_active_services() {
+ cd $INIT_PATH
+ list=""
+ for el in $(ls | grep -v 'rcS' | grep -v "grep")
+ do
+ if [ -x $el ]; then
+ # This is a hack to the += operator
+ list=$(echo -n "$list $el ")
+ fi
+ done
+ echo $list
+}
+
+# This function lists the inactive services that do not necessarily match the rcS syntax
+# and that are not executables
+
+get_inactive_services() {
+ cd $INIT_PATH
+ list=""
+ for el in $(ls | grep -v 'rcS' | grep -v "grep")
+ do
+ if [ ! -x $el ]; then
+ # This is a hack to the += operator
+ list=$(echo -n "$list $el ")
+ fi
+ done
+ echo $list
+}
+
+# This function shows the active services by calling the get_active_services function
+# and showing this in a fancier way
+
+show_active_services()
+{
+echo "List of active services :
+-------------------------
+Priority Name"
+ if [ -n "$(get_active_services "")" ]; then
+ for service in $(get_active_services "")
+ do
+ echo -n " "
+ # This is a hack to tr -d '[:alpha:]'
+ echo -n $service | sed -e 's/S*[a-z]*//g'
+ echo -n " "
+ # This is a hack to tr -d '[:digit:]'
+ echo $service | sed -e 's/^S[0-9]*//g'
+ done
+ else
+ echo "No active service"
+ fi
+ echo "-------------------------"
+}
+
+# This function shows the inactive services by calling the get_inactive_services function
+# and showing this in a fancier way
+
+show_inactive_services()
+{
+echo "List of inactive services :
+-------------------------
+Priority Name"
+
+ if [ -n "$(get_inactive_services "")" ]; then
+ for service in $(get_inactive_services "")
+ do
+ echo -n " "
+ echo -n $service | sed -e 's/S*[a-z]*//g'
+ echo -n " "
+ echo $service | sed -e 's/^S[0-9]*//g'
+ done
+ else
+ echo "No inactive service"
+ fi
+ echo "-------------------------"
+}
+
+# This function deactivates a service by making it not executable
+# it also checks that the service is not protected
+
+deactivate_service()
+{
+ show_active_services ""
+ echo "Choose the service you want to deactivate by either it's name or number"
+ read service
+ if [ -z "$service" ]; then
+ echo "Please enter a valid reference"
+ else
+ cd $INIT_PATH
+ if [ "$(is_protected_service "$service")" = "0" ]; then
+ chmod -x $(ls -1 | grep $service | grep -v "grep" | uniq)
+ echo "service $service deactivated !"
+ else
+ echo "---------------------------------------
+ /!\\ Service $service is protected /!\\"
+ fi
+ fi
+}
+
+# This function activates a service and does not do many checks because we don't really
+# care activating a service that is already activated
+
+activate_service()
+{
+ show_inactive_services ""
+ echo "Choose the service you want to activate by either it's name or number"
+ read service
+ if [ -z "$service" ]; then
+ echo "Please enter a valid reference"
+ else
+ cd $INIT_PATH
+ chmod +x $(ls -1 | grep $service | grep -v "grep" | uniq)
+ echo "Service $service activated"
+ fi
+}
+
+# This is the main function *cough* looks like the C-equivalent
+# void main(void) !!
+
+main()
+{
+echo "--------------------------------
+OpenWrt rcconf-like utility $VERSION
+---------------------------------
+1 - Show active system services
+2 - Show inactive system services
+3 - Desactivate a system service
+4 - Reactivate a system service
+5 - Quit this script
+--------------------------------"
+read menu
+ case $menu in
+ 1)
+ clear;
+ show_active_services "";
+ main "";
+ clear
+ ;;
+ 2)
+ clear;
+ show_inactive_services "";
+ main "";
+ clear;
+ ;;
+ 3)
+ clear;
+ deactivate_service "";
+ main "";
+ clear;
+ ;;
+ 4)
+ clear;
+ activate_service "";
+ main "";
+ clear;
+ ;;
+ 5)
+ clear;
+ exit 0
+ ;;
+ *)
+ main "";
+ ;;
+esac
+}
+
+# Finally call our entry point to this shell script
+
+main ""
Property changes on: branches/buildroot-ng/openwrt/package/base-files/default/sbin/rcconf
___________________________________________________________________
Name: svn:executable
+ *