Skip to content
Snippets Groups Projects
Commit 2c004c9e authored by Pietsch, Martin's avatar Pietsch, Martin
Browse files

refactored functions

parent c0713183
No related branches found
No related tags found
No related merge requests found
# installTcPackages - install tiny core packages
# parameter:
# space seperated list of package names
# $@ - list of package names
# return:
# 0 is installed
# 1 something went wrong
installTcPackages(){
while [ $# -ne 0 ]
while [ $# -gt 0 ];
do
sudo -u tc tce-load -w -i $1
su tc -c "tce-load -s -w -i $1" 2>&1 >/dev/null
shift
done
}
# 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}
}
start_chroot(){
sudo mkdir -p /mnt/debinst/{dev/pts,proc,sys}
sudo mount /dev /mnt/debinst/dev --bind
sudo mount devpts /mnt/debinst/dev/pts -t devpts
sudo mount none /mnt/debinst/proc -t proc
sudo mount none /mnt/debinst/sys -t sysfs
# 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
sudo LANG=C.UTF-8 chroot /mnt/debinst $1
LANG=C.UTF-8 chroot /target $1
sudo umount /mnt/debinst/sys
sudo umount /mnt/debinst/proc
sudo umount /mnt/debinst/dev/pts
sudo umount /dev /mnt/debinst/dev
}
\ No newline at end of file
umount /target/sys
umount /target/proc
umount /target/dev/pts
umount /dev /target/dev
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment