Files
new_install/operation/exec_finish_install.sh
fling 9b4be38571 modified: ../operation/exec_finish_install.sh
copy /var/installinstall.xml into /var/log/
2010-11-02 15:44:55 +08:00

99 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# DESCRIPTION: chroot $TARGET excute script under /var/finish_install/.
# copy 99finish_install to /var/finish_install/, then one
# by one copy the script in /var/finish_install/ to $TARGET
# with sequence, and then chroot $TARGET to execte it.
#
# SCRIPT NAME: exec_finish_install.sh
#
# Input: stdin
# 1. script name which need run after installation
#
# Output:
# NULL
# Return value:
# dependency return value of execute script, if 0 is success.
#
# AUTHOR: Qin Bo
#
# EMAIL: bqin@linx-info.com
#
# DATE: 2010-08-27
#
# HISTORY:
# REVISOR DATE MODIFICATION
# Qin Bo 2010-08-27 create
#
#
#
source ./functions
prep ()
{
local mp
if [ ! -d $FINISH_INSTALL_DIR ];then
mkdir -p $FINISH_INSTALL_DIR
fi
for mp in /dev /proc /sys
do
mount --bind -n $mp "$TARGET$mp"
done
}
# copy the script to $TARGET/opt, and chroot execute it
exec_script ()
{
local src
local src_name
src="$1"
src_name=$(basename $src)
cp $src "$TARGET/opt"
chroot $TARGET "/opt/$src_name" >>$DEV_LOG 2>&1 && rm -f "$TARGET/opt/$src_name"
}
main ()
{
local line
local base
local script
prep
while read line ;do
if [ -n "$line" ];then
cp $line $FINISH_INSTALL_DIR/
else
break
fi
done
# run all the script in /var/finish_install,
# execute sequence through number of script name
for script in "$FINISH_INSTALL_DIR"/*; do
base=$(basename $script | sed 's/[0-9]*//')
if [ -x "$script" ];then
info "Running $base"
exec_script $script
erv
else
warn "Unable to execute $script"
fi
done
info "Running finish install success"
[ ! -c "$LOG_FILE" ] && cp $LOG_FILE "$TARGET/var/log"
[ ! -c "/var/install/install.xml" ] && cp "/var/install/install.xml" "$TARGET/var/log"
[ ! -c "$DEV_LOG" ] && cp $DEV_LOG "$TARGET/var/log" || true
}
FINISH_INSTALL_DIR="/var/finish_install"
main "$@"