Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-initramfs.git;a=commitdiff;h=5aadb56f8bd2258d7d8cf869c74a4978f26f19ac

commit 5aadb56f8bd2258d7d8cf869c74a4978f26f19ac
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Thu Nov 5 20:19:44 2009 +0100

create_functions.sh
*added some functions for create initramfs and usblive

diff --git a/create_functions.sh b/create_functions.sh
new file mode 100644
index 0000000..a626d01
--- /dev/null
+++ b/create_functions.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+NORMAL="\033[0m"
+WARN="\033[33;1m"
+BAD="\033[31;1m"
+BOLD="\033[1m"
+GOOD="\033[32;1m"
+
+##########################################################
+#functions
+##########################################################
+getBoxWidth ()
+{
+let boxWidth=$(echo $message | awk '{len=length($0)+4} {rem=len%10} \
+{len=len-(rem)+(rem > 0)*10} {if(len > 70) {print 70} else {print len}}')
+return
+}
+
+showMessageBox()
+{
+getBoxWidth
+dialog --backtitle "$BACK_TITLE" \
+--title "$title" \
+--msgbox "\n$message" \
+$boxHeight $boxWidth
+return
+}
+
+checkUser()
+{
+local user="$(whoami)"
+
+if [ $user != "root" ]; then
+ title="acced denied"
+ message="you should launch this script as root"
+ let boxHeight=7
+ showMessageBox
+
+ exit 1
+fi
+}
+
+# msg functions arguments
+# $1 string
+# $2 hide flag
+
+function good_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} 
${NORMAL}"
+}
+
+function bad_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       if [ "$2" != 1 ]
+       then
+               echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
+       fi
+}
+
+function warn_msg() {
+       msg_string=$1
+       msg_string="${msg_string:-...}"
+       [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} 
${NORMAL}"
+}
+
+Fsed() {
+       for i in ${@:3:$#}; do
+               good_msg "Using sed with file: $i"
+               sed -i -e "s|$1|$2|g" "$i" || Fdie
+       done
+}
+
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to