slitaz-base-files view rootfs/usr/lib/slitaz/libtaz-modules/commons @ rev 123

Add libtaz minus report module. I added config options for tazpkg-web in slitaz.conf. Also added a BASE_MIRROR variable so it can be changed.
author Christopher Rogers <slaxemulator@gmail.com>
date Thu Apr 12 14:05:36 2012 +0000 (2012-04-12)
parents
children
line source
1 status()
2 {
3 local CHECK=$?
4 echo -en "\\033[70G[ "
5 if [ $CHECK = 0 ]; then
6 echo -en "\\033[1;32mOK"
7 else
8 echo -en "\\033[1;31mFailed"
9 fi
10 echo -e "\\033[0;39m ]"
11 }
13 get_config()
14 {
15 if [ -f "./`basename $0`.conf" ]; then
16 . ./`basename $0`.conf
17 elif [ -f "/etc/slitaz/`basename $0`.conf" ]; then
18 . /etc/slitaz/`basename $0`.conf
19 else
20 echo -e "\nUnable to find the configuration file : /etc/slitaz/`basename $0`.conf" >&2
21 echo -e "Please read the `basename $0` documentation.\n" >&2
22 exit 1
23 fi
24 }
26 # The classic SliTaz check_root function used in nearly all SliTaz tools.
27 check_root()
28 {
29 [ $(id -u) = 0 ] && return
30 echo -e "\nYou must be root to run `basename $0` with this option." >&2
31 echo -e "Please type 'su' and root password to become super-user.\n" >&2
32 exit 1
33 }
35 # A classic check_dir function: - create directory if needed and echo about it.
36 # Return error if directory is created (to chain other commands with ||)
37 check_dir()
38 {
39 if ! [ -d "$1" ]; then
40 echo -n "Creating $1..."
41 mkdir -p "$1"
42 status
43 return 1
44 fi
45 }
47 # Install package if missing.
48 check_pkg()
49 {
50 if ! [ -d $INSTALLED/$1 ]; then
51 # report step "Installing package : $1"
52 tazpkg get-install $1
53 # report end-step
54 fi
55 }
57 # Display a horizontal line, can be used for a clearer script.
58 horizontal_line()
59 {
60 echo "================================================================================"
61 }
63 # Store -- options in a variable.
64 # Test phase.
65 # Need to add something to filter options and report errors in case option is not
66 # listed and used by the command.
67 get_options()
68 {
69 if echo "$log_command" | fgrep -q ' '--help; then
70 echo "Available options for $(echo `basename "$log_command"` | cut -d ' ' -f 1,2) : $get_options_list"
71 exit 0
72 fi
73 for get_option in $(echo "$log_command" | tr ' ' '\n' | grep ^-- | sed 's/^--//'); do
74 if [ "${get_options_list/${get_option%%=*}}" = "$get_options_list" ]; then
75 echo "Option ${get_option%%=*} is incorrect, valid options are : $get_options_list". >&2
76 exit 1
77 fi
78 if [ "$get_option" = "${get_option/=}" ]; then
79 export $get_option=yes
80 else
81 export $get_option
82 fi
83 done
84 }