beautysh -f src/remaster.sh

This commit is contained in:
6543 2018-05-22 01:17:02 +02:00
parent 756d389c6d
commit cd15118bb8

View File

@ -10,37 +10,37 @@


#set functions #set functions
[ -d "<LIBDIR>" ] || { [ -d "<LIBDIR>" ] || {
echo "ERROR Librarys not found" echo "ERROR Librarys not found"
exit 1 exit 1
} }


#read main setting #read main setting
if [ -f "<ROOTDIR>/etc/remaster/config.cfg" ]; then if [ -f "<ROOTDIR>/etc/remaster/config.cfg" ]; then
source "<ROOTDIR>/etc/remaster/config.cfg" source "<ROOTDIR>/etc/remaster/config.cfg"
else else
if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg" ]; then if [ -f "<ROOTDIR>/etc/remaster/config.sample.cfg" ]; then
source "<ROOTDIR>/etc/remaster/config.sample.cfg" source "<ROOTDIR>/etc/remaster/config.sample.cfg"
else else
echo "ERROR config not found" echo "ERROR config not found"
exit 1 exit 1
fi fi
fi fi
#check LOG #check LOG
{ {
[ -z "$log_file" ] && log_file="/tmp/remaster_`date '+%Y-%m-%d'`" [ -z "$log_file" ] && log_file="/tmp/remaster_`date '+%Y-%m-%d'`"


if [ -f "$log_file" ]; then if [ -f "$log_file" ]; then
echo > "$log_file" echo > "$log_file"
else else
#check if folder exist #check if folder exist
[ -d "${log_file%/*}" ] || { [ -d "${log_file%/*}" ] || {
# N-> exit 3 # N-> exit 3
echo "Directory for Log didnt exist" echo "Directory for Log didnt exist"
exit 3 exit 3
} }
#create LOG #create LOG
touch "$log_file" touch "$log_file"
fi fi
} }


##################################################################################### #####################################################################################
@ -189,8 +189,8 @@ iso_extract "$iso_source" "$iso_extr_dir" >> "$log_file"
# 3. Entpacken der Dateien des Live-Systems # 3. Entpacken der Dateien des Live-Systems
filesystem_img="`find "$iso_extr_dir" -name filesystem.squashfs`" filesystem_img="`find "$iso_extr_dir" -name filesystem.squashfs`"
[ -e "$filesystem_img" ] || { [ -e "$filesystem_img" ] || {
echo "### ERROR ### Image \"$iso_source\" has no \"filesystem.squashfs\"" >> "$log_file" echo "### ERROR ### Image \"$iso_source\" has no \"filesystem.squashfs\"" >> "$log_file"
on_exit 15 >> "$log_file" on_exit 15 >> "$log_file"
} }


filesystem_extract "$filesystem_img" "$chroot_path" >> "$log_file" filesystem_extract "$filesystem_img" "$chroot_path" >> "$log_file"
@ -203,8 +203,8 @@ error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_fil


# 5. Setzen der Netzwerk-Einstellungen: # 5. Setzen der Netzwerk-Einstellungen:
[ -n "$proxy_host" ] && { [ -n "$proxy_host" ] && {
proxy_enable "$chroot_path" "$proxy_host" "$proxy_port" >> "$log_file" proxy_enable "$chroot_path" "$proxy_host" "$proxy_port" >> "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file" error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
} }


dns_set "$chroot_path" "$domain" "$nameserver" >> "$log_file" dns_set "$chroot_path" "$domain" "$nameserver" >> "$log_file"
@ -244,8 +244,8 @@ error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_fil


#Überprüfen ob alles ausgehängt wurde #Überprüfen ob alles ausgehängt wurde
[ "`chroot_is_mounted "$chroot_path"`" == "true" ] && { [ "`chroot_is_mounted "$chroot_path"`" == "true" ] && {
echo "### ERROR ### Cant Unmount Chroot!" >> "$log_file" echo "### ERROR ### Cant Unmount Chroot!" >> "$log_file"
on_exit 21 >> "$log_file" on_exit 21 >> "$log_file"
} }


# 10. Packen und Ersetzen der Dateien des Live-Systems # 10. Packen und Ersetzen der Dateien des Live-Systems
@ -257,19 +257,19 @@ error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_fil


# wenn iso gewünscht # wenn iso gewünscht
[ "$iso_aim" != "" ] && { [ "$iso_aim" != "" ] && {
iso_create "$chroot_path" "$iso_extr_dir" "$iso_aim" "$iso_lable" >> "$log_file" iso_create "$chroot_path" "$iso_extr_dir" "$iso_aim" "$iso_lable" >> "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file" error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
} }


# wenn filesystem gewünscht # wenn filesystem gewünscht
[ "$squashfs_path" != "" ] && { [ "$squashfs_path" != "" ] && {
#wen bereits forhanden dann löschen #wen bereits forhanden dann löschen
[ -f "$squashfs_path" ] && rm "$squashfs_path" [ -f "$squashfs_path" ] && rm "$squashfs_path"
cp "$filesystem_img" "$squashfs_path" >> "$log_file" cp "$filesystem_img" "$squashfs_path" >> "$log_file"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file" error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"


chmod 666 "$squashfs_path" chmod 666 "$squashfs_path"
error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file" error_level="$?"; [ "$error_level" != "0" ] && on_exit $error_level >> "$log_file"
} }


chmod 666 "$iso_aim" "$filesystem_img" >> "$log_file" chmod 666 "$iso_aim" "$filesystem_img" >> "$log_file"