Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master imp-data-simpleinit by Arjan Bouter (d57d1993d9ad08db463b69479e2617f660460911)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Arjan Bouter <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master imp-data-simpleinit by Arjan Bouter (d57d1993d9ad08db463b69479e2617f660460911)
  • Date: Tue, 24 May 2011 08:02:01 -0500

GIT changes to master imp-data-simpleinit by Arjan Bouter
<abouter AT sourcemage.org>:

modules/liblist | 196
++++++++++++++++++++++++++++++++++++++++++++++++++-
modules/libundefined | 15 ---
simpleinit.def | 2
3 files changed, 195 insertions(+), 18 deletions(-)

New commits:
commit d57d1993d9ad08db463b69479e2617f660460911
Author: Arjan Bouter <abouter AT sourcemage.org>
Commit: Arjan Bouter <abouter AT sourcemage.org>

imp-data-simpleinit: created missing functions and added CONFIGROOT to
simpleinit.def

diff --git a/modules/liblist b/modules/liblist
index 1634cf6..24bc3de 100644
--- a/modules/liblist
+++ b/modules/liblist
@@ -1,14 +1,204 @@
simpleinit_list_installed(){
- ls -l "$RUNLEVELROOT"/*/* | grep -v runlevel.config | sed -e
's!^.*/%\(.*\)/!\1 !'
+ local filelist=""
+ local file=""
+ GLOBIGNORE="*/runlevel.config"
+ filelist=(${RUNLEVELROOT}/*/*)
+ for file in ${filelist[@]}; do
+ echo "${file##*/}"
+ done
}

simpleinit_list_spell(){
local spell=$1
+ local file=s""
if [[ -d $SCRIPTROOT/$spell ]]; then
- cd $SCRIPTROOT/$spell
- $LS --color=none | grep -v ".conf"
+ GLOBIGNORE="*.conf"
+ for files in $SCRIPTROOT/$spell/* ; do
+ echo "${files##*/}"
+ done
else
message "No scripts exists for this spell or spell does not exist"
fi
+}
+
+simpleinit_activate_script(){
+ local script="$1"
+ local foundscript=""
+ local scriptfile=""
+
+ if [[ -z $script ]]; then
+ message "no scriptname passed, quitting"
+ return 1
+ else
+ shopt -s nullglob
+ foundscript=("$RUNLEVELROOT"/*/"$script")
+ shopt -u nullglob
+ if [[ "${#foundscript[@]}" = 0 ]]; then
+ message "$script was not found in your runlevel dirs"
+ return 1
+ elif [[ "${#foundscript[@]}" -gt 1 ]]; then
+ message "this is bad... $script was found multiple times in your
runlevel dirs"
+ message "all of them will be enabled but you should investigate"
+ fi
+ for scriptfile in "${foundscript[@]}"; do
+ if [[ ! -x "$scriptfile" ]]; then
+ message "$scriptfile is not installed"
+ return 1
+ elif [[ ! -f "$scriptfile" ]]; then
+ message "$scriptfile is not a regular file"
+ return 1
+ else
+ if [[ -x "$scriptfile" ]]; then
+ message "Service $script already enabled."
+ else
+ chmod ug+x "$scriptfile" && echo "Service $script successfully
enabled." ||
+ message "an error occurred enabling service $script"
+ fi
+ fi
+ done
+ fi
+}
+
+simpleinit_deactivate_script(){
+ local script="$1"
+ local foundscript=""
+ local scriptfile=""
+
+ if [[ -z $script ]]; then
+ message "no scriptname passed, quitting"
+ return 1
+ else
+ shopt -s nullglob
+ foundscript=("$RUNLEVELROOT"/*/"$script")
+ shopt -u nullglob
+ if [[ "${#foundscript[@]}" = 0 ]]; then
+ message "$script was not found in your runlevel dirs"
+ return 1
+ elif [[ "${#foundscript[@]}" -gt 1 ]]; then
+ message "this is bad... $script was found multiple times in your
runlevel dirs"
+ message "all of them will be disabled but you should investigate"
+ message "${foundscript[@]}"
+ fi
+ for scriptfile in "${foundscript[@]}"; do
+ if [[ ! -x "$scriptfile" ]]; then
+ message "$scriptfile is not installed"
+ return 1
+ elif [[ ! -f "$scriptfile" ]]; then
+ message "$scriptfile is not a regular file"
+ return 1
+ else
+ if [[ ! -x "$scriptfile" ]]; then
+ message "Service $script already disabled."
+ else
+ chmod ug-x "$scriptfile" && echo "Service $script successfully
disabled." ||
+ message "an error occurred disabling service $script"
+ fi
+ fi
+ done
+ fi
+}
+
+function simpleinit_remove_script(){
+ local script="$1"
+ local foundscript=""
+ local scriptfile=""
+
+ if [[ -z $script ]]; then
+ message "no scriptname passed, quitting"
+ return 1
+ else
+ shopt -s nullglob
+ foundscript=("$RUNLEVELROOT"/*/"$script")
+ shopt -u nullglob
+ if [[ "${#foundscript[@]}" = 0 ]]; then
+ message "$script was not found in your runlevel dirs"
+ return 1
+ elif [[ "${#foundscript[@]}" -gt 1 ]]; then
+ message "this is bad... $script was found multiple times in your
runlevel dirs"
+ message "${foundscript[@]}"
+ message "you should investigate while I take a break"
+ return 1
+ else
+ for scriptfile in "${foundscript[@]}"; do
+ if [[ ! -f "$scriptfile" ]]; then
+ message "$scriptfile is not a regular file, aborting"
+ return 1
+ else
+ rm "$scriptfile" && echo "Service $script successfully removed."
||
+ message "an error occurred removing service $script"
+ fi
+ done
+ fi
+ fi

}
+
+function simpleinit_install_spell_script(){
+ local spell=$1
+ local script=$2
+ if [[ -z "${script}" ]]; then
+ simpleinit_install_all_spell_scripts
+ else
+ local scriptfile="$SCRIPTROOT/$spell/$script"
+ if [[ -e "${scriptfile}" ]]; then
+ local runlevel="$(grep ^RUNLEVEL "${scriptfile}"|sed
's/.*=//')"
+ if [[ -z "$runlevel" ]]; then
+ message "no runlevel specified in ${scriptfile},
aborting"
+ return 1
+ else
+ message "installing ${scriptfile##*/} into runlevel
$runlevel"
+ cp "${scriptfile}" "${RUNLEVELROOT}/%$runlevel/"
+ if [[ -e "${scriptfile}.conf" ]]; then
+ if [[ -e "${CONFIGROOT}/${scriptfile##*/}" ]];
then
+ cp "${scriptfile}.conf"
"${CONFIGROOT}/${scriptfile##*/}.default"
+ else
+ cp "${scriptfile}.conf"
"${CONFIGROOT}/${scriptfile##*/}"
+ fi
+ fi
+ fi
+ fi
+
+
+ fi
+}
+
+function simpleinit_install_all_spell_scripts(){
+ local spell=$1
+ local file=""
+ local filelist=""
+ if [[ -d $SCRIPTROOT/$spell ]]; then
+ shopt -s nullglob
+ GLOBIGNORE="*.conf"
+ filelist=($SCRIPTROOT/$spell/*)
+ shopt -u nullglob
+ if [[ -z "${filelist[0]}" ]]; then
+ message "could not find script any file for spell $spell"
+ return 1
+ fi
+ for file in ${filelist[@]} ; do
+ if [[ -f "${file}" ]]; then
+ local runlevel="$(grep ^RUNLEVEL "${file}"|sed 's/.*=//')"
+ if [[ -z "$runlevel" ]]; then
+ message "no runlevel specified in ${file}, aborting"
+ return 1
+ else
+ message "installing ${file##*/} into runlevel $runlevel"
+ cp "${file}" "${RUNLEVELROOT}/%$runlevel/"
+ if [[ -e "${file}.conf" ]]; then
+ if [[ -e "${CONFIGROOT}/${file##*/}" ]]; then
+ cp "${file}.conf"
"${CONFIGROOT}/${file##*/}.default"
+ else
+ cp "${file}.conf"
"${CONFIGROOT}/${file##*/}"
+ fi
+ fi
+ fi
+ else
+ message "could not find script file ${file##*/}"
+ fi
+ done
+ else
+ message "No scripts exist for this spell or the spell does not exist"
+ fi
+}
+
+
diff --git a/modules/libundefined b/modules/libundefined
index 89d5989..8b13789 100644
--- a/modules/libundefined
+++ b/modules/libundefined
@@ -1,16 +1 @@
-function simpleinit_install_spell_script(){
- message "Not yet implemented"
-}
-function simpleinit_install_all_spell_scripts(){
- message "Not yet implemented"
-}
-function simpleinit_remove_script(){
- message "Not yet implemented"
-}
-function simpleinit_activate_script(){
- message "Not yet implemented"
-}
-function simpleinit_deactivate_script(){
- message "Not yet implemented"
-}

diff --git a/simpleinit.def b/simpleinit.def
index 661b180..d72c484 100644
--- a/simpleinit.def
+++ b/simpleinit.def
@@ -13,3 +13,5 @@ SCRIPTROOT="/lib/imp/scripts/simpleinit"
# where the various libs are stored
MODULEROOT="/lib/imp/modules/simpleinit"

+# where the init configuration files are stored
+CONFIGROOT="/etc/sysconfig"



  • [SM-Commit] GIT changes to master imp-data-simpleinit by Arjan Bouter (d57d1993d9ad08db463b69479e2617f660460911), Arjan Bouter, 05/24/2011

Archive powered by MHonArc 2.6.24.

Top of Page