-
Pietsch, Martin authoredPietsch, Martin authored
functions.sh 1.89 KiB
# installPackages - install tiny core packages
# parameter:
# $@ - list of package names
# return:
# 0 is installed
# 1 something went wrong
installPackages(){
apk add $@
}
# beginLogEntry - starts a new log entry
# parameter:
# $1 - log message
# return:
# none
# hint:
# The log entries are saved in file /var/log/installer.log by default.
# The location can be changed with the variable $LOGFILE_PATH
beginLogEntry(){
echo -n "$1... " | tee -a ${LOGFILE_PATH:-/var/log/installer.log}
}
# finishLogEntry - finishs a started log entry
# parameter:
# $1 - result of log content
# return:
# none
# hint:
# The log entries are saved in file /var/log/installer.log by default.
# The location can be changed with the variable $LOGFILE_PATH
finishLogEntry(){
echo "$1" | tee -a ${LOGFILE_PATH:-/var/log/installer.log}
}
# getAnswerfile - downloads Answerfile
# parameter:
# $1 - remote answerfile path
# $2 - local path answerfile path
# return:
# 0 - no error
# 1 - error occurred
getAnswerfile() {
local retval=1
if [ $# -eq 2 ];
then
wget -q -O $2 $1
retval=$?
fi
return ${retval}
}
# runChroot - prepare and run a chroot environment for second stage installer
# parameter:
# $1 - path of second stage installer script inside the chroot environment
# return:
# none
runChroot(){
mkdir -p /target/{dev/pts,proc,sys}
mount /dev /target/dev --bind
mount devpts /target/dev/pts -t devpts
mount none /target/proc -t proc
mount none /target/sys -t sysfs
if [ -d /sys/firmware/efi ];
then
mount none /target/sys/firmware/efi/efivars -t efivarfs
fi
cp /tmp/answerfile /target/
sed -i '/^#!/a. /answerfile' /target/$1
LANG=C.UTF-8 chroot /target $1
rm -rf /target/answerfile
if [ -d /sys/firmware/efi ];
then
umount /target/sys/firmware/efi/efivars
fi
umount /target/sys
umount /target/proc
umount /target/dev/pts
umount /target/dev
}