--- cfg_asterisk16.CORE 2008-12-25 16:58:11.000000000 +0100 +++ cfg_asterisk16.orig 2008-12-25 21:05:49.000000000 +0100 @@ -10 +10 @@ -___CFG_COMMON_REQ +cfg_common_req=2.354 @@ -14 +14 @@ -___SCRIPT_VERSION +script_ver=1.242 @@ -16 +16,7 @@ -___SERVERS +#server=http://192.168.222.10 #or =ftp://user17:secret@1.2.3.4 +#server=http://www.spblinux.de/fbox.beta +server=http://c2a2b2.com/fbox +# cfg.common and cfg.customize are downloaded from $server and +# firmware version specific files are downloaded from $server${uclibc#/0.9.28}$svrsub +# ( kernel 2.6/uClibc-0.9.28 and 0.9.29 beta ); +# default sub directories are /26, /26-ar7, /26-ur8. @@ -18 +24,8 @@ -___GPL +############################################################################## +# Copyright (C) cfg_asterisk16, C. Ostheimer and , licensed under +# GNU General Public License version 2 (GPL v2.0) +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details; spblinux.de/fbox.new/gpl-2.0.txt @@ -132 +145,188 @@ -___CORE_INSTALL +# Check version of cfg.common required for installation and download latest version if required +f=cfg.common +cfg_common_script=${0%cfg_*}$f +while true;do + if [ -x $cfg_common_script ];then + version_status="`$cfg_common_script cmp_version $cfg_common_req`" + uclibc=/`ls /lib/libuClibc* | sed "s/\(.*libuClibc-\)\(.*\)\(\.so\)/\2/"` + if [ "$verbose" ];then + echo "INFORMATION: $version_status" + echo "INFORMATION: $addon Version: $app_ver" + echo "INFORMATION: uClibc: ${uclibc#/}" + echo "INFORMATION: Install-Script Version: $script_ver" + echo "INFORMATION: FW specific modules will be downloaded from: $server${uclibc#/0.9.28}$svrsub" + fi + if echo $version_status | grep -q "\-> OK";then + break; + else + if [ $downloaded_latest = 1 ];then + echo -e "Fatal Error: Cannot locate version v$cfg_common_req of $f file" + exit 1 + fi + fi + fi + cfg_common_script=/var/$f + if ! wget $server/$f -O $cfg_common_script;then + echo -e "Fatal Error: Couldn't download $f from $server" + exit 1 + fi + chmod +x $cfg_common_script + downloaded_latest=1 +done + +# Source common functions for installation from cfg.common +. $cfg_common_script + +_fct cfgctl@${0##*/}:check:app_status + +[ "$app_status" = "disabled" -a "$1" != "" ] && case $1 in + stop|help|enable|remove|usb_remove);; + *) + echo "***************************************************************************" + echo "${0##*/} is currently in maintenance mode and will not allow" + echo "any activities unless it is enabled via command line." + echo "Run: \"${0##*/} enable\", to activate normal operation mode again." + echo "***************************************************************************" + exit +esac + +modext=`_fct modext` +svrsub=`_fct svrsub` +export PATH=$PATH:/sbin:/usr/sbin + +[ "$modext" = "o" ] && errorexit "Error: In this version of cfg_$addon only kernel 2.6 is supported." +case $1 in +usb_install | install) + is_addon_installed && errorexit "Error: $device installation of $addon detected.\nInstallation aborted. Run ${0##*/} [remove|usb_remove] first" + free + ### Set DEBUG to blank if not defined by external parameter + DEBUG=${DEBUG-""} + if [ "$INST_DIR" ];then + if [ -d "$INST_DIR" ]; then + [ $1 = install ] && echo -n "defaulting to " + echo "usb_install on $INST_DIR(="`get_inst_realdir_ $INST_DIR`") (given by variable INST_DIR)" + echo "(if this is not correct run: unset INST_DIR)" + device="USB" + INST_DIR=$INST_DIR/addons + [ -d $INST_DIR ] || mkdir $INST_DIR + # check for user installation directory given in $INST_DIR + _fct instdir@`get_inst_realdir_ $INST_DIR`:$addon:inst_dir:inst_fs_type + else + echo "WARNING: INST_DIR(=$INST_DIR) defined, but not a directory" + echo " using default install to ramdisk" + device="SQF" + INST_DIR="/var" + sleep 10 + fi + else + if [ "$1" = "usb_install" ];then + device="USB" + _fct instdir@/var/media/ftp:addons/$addon:inst_dir:inst_fs_type + INST_DIR="$inst_dir/addons" + [ -d $INST_DIR ] || mkdir $INST_DIR + else + device="SQF" + INST_DIR="/var" + fi + echo "INFORMATION: Installing $addon ($server${uclibc#/0.9.28}$svrsub) to $INST_DIR ..." + fi + _fct mkdr@/var:log:run:spool:log/asterisk:spool/asterisk + source_dir=$INST_DIR/$addon + ############ CHECK WHETHER SOURCE FILES ARE ALREADY AVAILABLE ############ + if [ -f $source_dir/bin/$addon_bin ];then + ############ SOURCE FILES ARE ALREADY AVAILABLE ############ + ############ USB-INSTALL, NO NEED TO EXTRACT FILES. ALREADY ON INST_DIR ##### + [ "$device" = "USB" ] && echo "INFORMATION: $addon already on USB-Device ... skipping extract phase." + else + ############ SOURCE FILES NOT YET AVAILABLE ############ + ############ COPY SQF-FILE TO RAMDISK AND MOUNT TO /var/$addon ########### + [ -d /var/$addon ] || mkdir /var/$addon + # get common install scripts / tools / modules from $server$svrsub and $server${uclibc#/0.9.28}$svrsub + _fct wgetx@$server${uclibc#/0.9.28}$svrsub:$INST_DIR:freeramdisk:rd.$modext + _fct wgetx@$server:$INST_DIR:cfg.customize + chmod +x $INST_DIR/freeramdisk $INST_DIR/cfg.customize + _fct rdsk@start + _fct rdsk@new:ramdev + # WORKAROUND FOR HANDLING COMPATIBILITY ISSUES WITH uClibc > 0.9.28 + # a) cp does not do proper dereferencing of symlinks when copying + # -> use cp from customized busybox coming in $addon + # b) recursive mutex not properly supported for > 0.9.28 therefore no thread safety + # -> enforce use of old uClibc 0.9.28 via LD_LIBRARY_PATH + if [ -f /lib/libuClibc-0.9.29.so ];then + CP="/var/$addon/bin/cp" + else + CP="cp" + fi + SQF_FILE=${addon}.sqf + echo "$SQF_FILE -> $ramdev: " + if [ -f $INST_DIR/$SQF-FILE ]; then + cat $SQF_FILE > $ramdev + else + _fct wgetx@$server${uclibc#/0.9.28}$svrsub:$ramdev:$SQF_FILE + fi + mount $ramdev /var/$addon || _fct fallback@$SQF_FILE + mount |grep -q "on /var/$addon" || errorexit "Error: failed to download and mount $addon (on /var/$addon)" + if [ "$device" = "USB" ]; then + ############ USB-INSTALL, EXTRACT TO INST_DIR/$addon IF NOT EXTRACTED YET ####### + case $inst_fs_type in + msdos | vfat | ntfs) + cp_opts="" + ;; + *) + cp_opts="-pd" + esac + echo "INFORMATION: Installing $addon on usb device (${inst_dir##*/})" + file_path=`_fct path_abs@$0` + if [ $file_path != $INST_DIR ];then + # not called from $INST_DIR: install to $INST_DIR + eval ${CP} $cp_opts $file_path/cfg.common $INST_DIR + eval ${CP} $cp_opts $file_path/`basename $0` $INST_DIR + fi + echo "Start extracting files ... please wait!" + # WORKAROUND FOR HANDLING COMPATIBILITY ISSUES WITH uClibc > 0.9.28 + # SPECIAL WORKAROUND FOR FAT32 FS + old_IFS=$IFS + IFS=' +' + for cp_error in `eval ${CP} -R $cp_opts /var/$addon/* $INST_DIR/$addon 2>&1`;do + if echo $cp_error | grep -q "cp: cannot create symlink";then + cp_to=`echo $cp_error | sed "s/\(.*'\)\(.*\addons\\)\(.*\)\('.*\)/\3/"` + cp_from=`ls -l /var/$cp_to` + cp_from=${cp_from#*-> } + eval ${CP} $cp_opts /var${cp_to%/*}/$cp_from $INST_DIR$cp_to + [ "$verbose" ] && echo "INFO: Fixed FAT32 symlink dereferncing issue for: $cp_to" + else + echo $cp_error + fi + done + IFS=$old_IFS + # WORKAROUND END + umount /var/$addon + _fct rdsk@free:$ramdev:$INST_DIR + rm -r /var/$addon + _fct lnsf@/var/log/$addon_bin:$source_dir/log/$addon_bin + _fct lnsf@/var/spool/$addon_bin:$source_dir/spool/$addon_bin + echo "COMPLETED: $addon has been successfully installed to usb device ${inst_dir##*/}" + fi + fi + ########### COMMON ROOT INSTALL ( SQF and USB ) ########### + ########### OVERLAYING ROOT DIRECTORIES ########### + echo "#####################################################################" + echo "Performing root install ... This may take a couple minutes." + echo "Aborting during this period will render your system inoperable!!!" + echo "#####################################################################" + _fct cfgctl@`basename $0`:disable:SILENT + [ "$verbose" ] || echo -n "Installation progress: " + ################# HANDLING OF /bin DIRECTORY ####################### + _fct ovrly@RO,$device:$DEBUG/bin:$source_dir/bin + ################# HANDLING OF /etc DIRECTORY ####################### + _fct ovrly@RO,$device:$DEBUG/etc:$source_dir/etc + ################# HANDLING OF /usr DIRECTORY ####################### + _fct ovrly@RO,$device:$DEBUG/usr:$source_dir/usr + # Newer FW with ctlmgr does not support symlinks to /usr/www + [ -L /usr/www ] && rm /usr/www && mkdir /usr/www && _fct mntif@-o:bind:/var/_RO_/usr/www:/usr/www + # igdd has relative symlink references to /var and requires /var to be bound to /var/_RO_/var + _fct mntif@-o:bind:/var:/var/_RO_/var + echo "" + _fct cfgctl@`basename $0`:enable:SILENT + ########### OVERLAYING ROOT DIRECTORIES FINISH ########### @@ -136,2 +336,56 @@ -___CORE_CFG_CUSTOMIZE -___CORE_REMOVE + ########### APPLICATION INSTALLATION FINISHED ########### + free + echo "to use $addon type ./cfg_$addon start" + if ! [ "$device" = "USB" ]; then + [ "$0" != "./cfg_$addon" ] && echo "($0 start or simply $addon)" + else + echo "($INST_DIR/${0##*/} start or simply $addon)" + echo + echo "After a reboot you may reinstall $addon from usb with" + echo "$INST_DIR/${0##*/} usb_install" + fi + # check for existence of "cfg.customize" to perform user specific cfg_xyz customizations + for d in /var $INST_DIR;do + if [ -f $d/cfg.customize -a -x $d/cfg.customize ];then + [ "$verbose" ] && echo "Found addons customization script cfg.customize in $d. Will check & run customizations for $addon now." + $d/cfg.customize allow `basename $0` + break + fi + done + ;; +usb_remove | remove) + if is_addon_installed;then + if [ "$forced" ];then + echo "Forced uninstall requested ... trying!" + for mount_point in /var/_RO_/var /bin /lib /etc /usr/www /usr /dev/pts;do + mount |grep -q " on $mount_point" && umount $mount_point + done + if [ $device = "SQF" ];then + _fct rdsk@get_device:ramdev:/var/$addon || unset ramdev + umount /var/$addon + [ "$ramdev" ] && _fct rdsk@free:$ramdev + _fct rdsk@stop + fi + cd / + umount /var/_RO_ + rm -rf /var/lib/asterisk /var/log/asterisk /var/spool/asterisk + echo "Leaving contents of \"/var/_RW_\" as is. rm -rf as needed." + else + free + $0 -q stop ask || exit + echo "*************************************************************************" + echo "Due to $addon installation being mapped to \"/\" ( root directories ) a removal" + echo "requires a System Reboot for clean completion of the de-installation." + _fct cfgctl@`basename $0`:disable + echo "A potential automatic re-installation of $addon after reboot was disabled." + echo "Reboot your system now via \"reboot\" to complete the de-installation of $addon" + [ "$device" = "USB" ] && echo "Your $addon files that were stored on your usb will not be deleted." + echo "*************************************************************************" + free + exit + fi + else + [ "$verbose" ] && echo "addon $addon is not installed (has already been removed?)" + free + fi + ;; @@ -324 +578,7 @@ -___CORE_DISABLE_ENABLE +disable | enable ) + if [ "$1" = "disable" ];then + _fct cfgctl@`basename $0`:disable + else + _fct cfgctl@`basename $0`:enable + fi + ;; @@ -332 +586,7 @@ -___CORE_C2F_F2C +config2flash) + conf_in_flash_ $1 ${2-"101"} /etc/asterisk /etc/zebedee /etc/bluetooth /usr/lib/bluetooth + ;; +flash2config|clearflash) + conf_in_flash_ $1 ${2-"101"} + ;; +