Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #dummy first line
- #!/bin/bash
- #
- #
- # remastersys-installer is an alternative installer for remastered livecd/dvd's
- #
- #
- # Created by Tony "Fragadelic" Brijeski
- #
- # Copyright 2008,2009 Under the GNU GPL2 License
- #
- # Originally Created September 12th,2008
- #
- #
- #
- #
- # This script requires either zenity or dialog to run
- #
- # checking to make sure script is running with root privileges
- testroot="`whoami`"
- if [ "$testroot" != "root" ]; then
- echo " Must be run as root - exiting"
- exit 1
- fi
- # set options depending on mode - text or gui
- testdialog=`which dialog`
- DIALOG="`which dialog`"
- HEIGHT="17"
- WIDTH="50"
- MENUHEIGHT="12"
- TITLE="--title "
- TEXT=""
- ENTRY="--inputbox "
- MENU="--menu"
- YESNO="--yesno "
- MSGBOX="--msgbox "
- PASSWORD="--passwordbox "
- PARTITIONPROG="cfdisk"
- TITLETEXT="Remastersys Live Installer"
- if [ "$1" = "gui" -o "$2" = "gui" ]; then
- GUI="$DISPLAY"
- fi
- if [ "$GUI" != "" ]; then
- testzenity=`which zenity`
- if [ "$testzenity" = "" ]; then
- echo " Zenity not present - proceeding to install zenity"
- apt-get -y -q install zenity
- testzenity=`which zenity`
- fi
- testgparted=`which gparted`
- if [ "$testgparted" = "" ]; then
- echo " Gparted not present - proceeding to install gparted"
- apt-get -y -q install gparted
- fi
- if [ "$testzenity" != "" ]; then
- DIALOG="`which zenity` --width=640 --height=400"
- TITLE="--title="
- TEXT="--text="
- ENTRY="--entry "
- ENTRYTEXT="--entry-text "
- MENU="--list --column=Pick --column=Info"
- YESNO="--question "
- MSGBOX="--info "
- PASSWORD="--entry --hide-text "
- testgparted=`which gparted`
- if [ "$testgparted" = "" ]; then
- PARTITIONPROG="xterm -e cfdisk"
- else
- PARTITIONPROG="gparted"
- fi
- TITLETEXT="Remastersys Live Installer"
- fi
- fi
- if [ "$DIALOG" = "" ]; then
- echo "Cannot find dialog or zenity. Exiting."
- exit 1
- fi
- progressbar () {
- tail -f /usr/bin/remastersys-installer | $DIALOG $TEXT"$@" --progress --pulsate --auto-close
- }
- . /etc/live.conf
- if [ "$1" = "intl" ]; then
- SETLOCALE="dpkg-reconfigure locales"
- SETCONSOLEDATA="dpkg-reconfigure console-data"
- SETXSERVER="dpkg-reconfigure xserver-xorg"
- fi
- if [ "$GUI" = "" ]; then
- #
- #TEXT MODE
- #
- #inform them what this is and ask if they want to continue
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"\n\nThis is an advanced installer.\n\nPlease use with caution.\n\nDo you want to continue?" $HEIGHT $WIDTH
- if [ $? != 0 ]; then
- exit 0
- fi
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"We need to prepare a swap and install partition now.\n\n$PARTITIONPROG will allow you to create the new partitions.\n\nYou must create or have 1 install partition and 1 swap partition.\n\nIf you already have partitions setup then just quit $PARTITIONPROG and installation will continue.\n\nClick OK to continue." $HEIGHT $WIDTH
- #choose the drive to partition
- DRIVES=`cat /proc/partitions | grep -v loop | grep -v major | grep -v "^$" | awk '{ print $4}' | grep -v "[0-9]"`
- for i in $DRIVES; do
- partdrive="$i"
- partdrivesize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- partdrivemenu="$partdrivemenu $partdrive $partdrivesize"
- done
- $DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a drive to partition. If the only option you see is to Quit the installer then no drives were found." $HEIGHT $WIDTH $MENUHEIGHT Exit "Quit the installer" $partdrivemenu 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- PARTDRIVE=`cat /tmp/choice.$$`
- else
- PARTDRIVE="Exit"
- fi
- rm /tmp/choice.$$
- if [ "$PARTDRIVE" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
- exit 1
- fi
- $PARTITIONPROG /dev/$PARTDRIVE
- #find the swap partition, swapon, and generate the uuid for fstab
- TARGETSWAP=`fdisk -l | grep swap | cut -d " " -f1`
- TARGETSWAP=`echo $TARGETSWAP | sed -r "s/\/dev\///g"`
- for i in $TARGETSWAP; do
- swappart="$i"
- swappartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- swappartmenu="$swappartmenu $swappart $swappartsize"
- done
- $DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a swap partition to use. If the only option you see is to Quit the installer then no swap partitions were found." $HEIGHT $WIDTH $MENUHEIGHT Exit "Quit the installer" $swappartmenu 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- SWAP=`cat /tmp/choice.$$`
- else
- SWAP="Exit"
- fi
- rm /tmp/choice.$$
- if [ "$SWAP" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
- exit 1
- fi
- #choose the partition to install to
- PARTITIONS=`cat /proc/partitions | grep "$PARTDRIVE" | awk '{ print $4}' | grep "[0-9]"`
- PARTINSTTEMP=`echo $PARTITIONS | sed -r "s/$SWAP//"`
- PARTINST=`echo $PARTINSTTEMP`
- for i in $PARTINST; do
- tempsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- if [ "$tempsize" = "1" ]; then
- PARTINST=`echo $PARTINST | sed -r "s/$i//"`
- fi
- done
- for i in $PARTINST; do
- part="$i"
- partsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- partmenu="$partmenu $part $partsize"
- done
- $DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a partition to install the root system to. If the only option you see is to Quit the installer then no partitions were found." $HEIGHT $WIDTH $MENUHEIGHT Exit "Quit the installer" $partmenu 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETPART=`cat /tmp/choice.$$`
- else
- TARGETPART="Exit"
- fi
- rm /tmp/choice.$$
- if [ "$TARGETPART" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
- exit 1
- fi
- HOMEINST=`echo $PARTINST | sed -r "s/$SWAP//" | sed -r "s/$TARGETPART//"`
- for i in $HOMEINST; do
- homepart="$i"
- homepartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- homepartmenu="$homepartmenu $homepart $homepartsize"
- done
- $DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a partition to install /home to. If the only option you see is root then no extra partitions were found." $HEIGHT $WIDTH $MENUHEIGHT root "put /home on the root partition" $homepartmenu 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- HOMEPART=`cat /tmp/choice.$$`
- else
- HOMEPART="root"
- fi
- rm /tmp/choice.$$
- #check mode and get new user info if it is a dist mode
- testmode=`grep "1000" /etc/passwd | grep -v "Live"`
- if [ "$testmode" = "" ]; then
- #root password entry section
- TARGETROOTPASS="1"
- TARGETROOTPASS2="2"
- while [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; do
- $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETROOTPASS=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root again." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETROOTPASS2=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- if [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again." $HEIGHT $WIDTH
- fi
- done
- rm /tmp/choice.$$
- #username input secton
- $DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new user's real name to be setup on the installed system." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETUSERFULLNAME=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- $DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new username to be setup on the installed system. Must be in lowercase letters only." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETUSER=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- #make sure its all lowercase just in case
- TARGETUSER="`echo $TARGETUSER | awk '{print tolower ($0)}'`"
- #password entry section
- TARGETPASS="1"
- TARGETPASS2="2"
- while [ "$TARGETPASS" != "$TARGETPASS2" ]; do
- $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETPASS=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER again." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETPASS2=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- if [ "$TARGETPASS" != "$TARGETPASS2" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again." $HEIGHT $WIDTH
- fi
- done
- rm /tmp/choice.$$
- fi
- #hostname setup
- $DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the hostname for the installed system." $HEIGHT $WIDTH 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- TARGETHOSTNAME=`cat /tmp/choice.$$`
- else
- exit 1
- fi
- rm /tmp/choice.$$
- #grub location
- $DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select where to install grub to.\n" $HEIGHT $WIDTH $MENUHEIGHT mbr "Master Boot Record of first drive" root "Root partition - safe choice if you use a different boot manager" 2>/tmp/choice.$$
- if [ "$?" = "0" ]; then
- GRUBLOCTEST=`cat /tmp/choice.$$`
- fi
- rm /tmp/choice.$$
- if [ "$GRUBLOCTEST" = "root" ]; then
- GRUBLOCTEXT="root partition of $TARGETPART"
- GRUBLOC="root"
- else
- GRUBLOCTEXT="master boot record"
- GRUBLOC=""
- fi
- dpkg-reconfigure tzdata
- $SETLOCALE
- $SETCONSOLEDATA
- $SETXSERVER
- if [ "$HOMEPART" != "root" ]; then
- HOMETEXT=", $HOMEPART will be formatted ext3 for /home "
- fi
- if [ "$testmode" = "" ]; then
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"Please verify that this information is correct.\nNew user $TARGETUSER will be created on the ext3 formatted $TARGETPART partition$HOMETEXT and grub will be installed to the $GRUBLOCTEXT.\n\nDo you want to continue?" $HEIGHT $WIDTH
- if [ $? != 0 ]; then
- exit 0
- fi
- else
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"Please verify that this information is correct.\nYour backup mode system will be installed on ext3 formatted $TARGETPART partition$HOMETEXT and grub will be installed to the $GRUBLOCTEXT.\n\nDo you want to continue?" $HEIGHT $WIDTH
- if [ $? != 0 ]; then
- exit 0
- fi
- fi
- #END TEXT MODE
- else
- #
- #GUI MODE
- #
- #inform them what this is and ask if they want to continue
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"\n\nThis is an advanced installer.\n\nPlease use with caution.\n\nDo you want to continue?"
- if [ $? != 0 ]; then
- exit 0
- fi
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"We need to prepare a swap and install partition now.\n\n$PARTITIONPROG will allow you to create the new partitions.\n\nYou must create or have 1 install partition and 1 swap partition.\n\nIf you already have partitions setup then just quit $PARTITIONPROG and installation will continue.\n\nClick OK to continue."
- #choose the drive to partition
- DRIVES=`cat /proc/partitions | grep -v loop | grep -v major | grep -v "^$" | awk '{ print $4}' | grep -v "[0-9]"`
- j="0"
- for i in $DRIVES; do
- partdrive="$i"
- partdrivesize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- partdrivemenu="$partdrivemenu $partdrive $partdrivesize"
- done
- PARTDRIVE=`$DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a drive to partition. If the only option you see is to Quit the installer then no drives were found." Exit "Quit the installer" $partdrivemenu`
- if [ "$PARTDRIVE" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
- exit 1
- fi
- $PARTITIONPROG /dev/$PARTDRIVE
- #find the swap partition, swapon, and generate the uuid for fstab
- #find the swap partition, swapon, and generate the uuid for fstab
- TARGETSWAP=`fdisk -l | grep swap | cut -d " " -f1`
- TARGETSWAP=`echo $TARGETSWAP | sed -r "s/\/dev\///g"`
- for i in $TARGETSWAP; do
- swappart="$i"
- swappartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- swappartmenu="$swappartmenu $swappart $swappartsize"
- done
- SWAP=`$DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a swap partition to use. If the only option you see is to Quit the installer then no swap partitions were found." Exit "Quit the installer" $swappartmenu`
- if [ "$SWAP" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
- exit 1
- fi
- #choose the partition to install to
- PARTITIONS=`cat /proc/partitions | grep "$PARTDRIVE" | awk '{ print $4}' | grep "[0-9]"`
- PARTINSTTEMP=`echo $PARTITIONS | sed -r "s/$SWAP//"`
- PARTINST=`echo $PARTINSTTEMP`
- for i in $PARTINST; do
- tempsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- if [ "$tempsize" = "1" ]; then
- PARTINST=`echo $PARTINST | sed -r "s/$i//"`
- fi
- done
- for i in $PARTINST; do
- part="$i"
- partsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- partmenu="$partmenu $part $partsize"
- done
- TARGETPART=`$DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a partition to install the root system to. If the only option you see is to Quit the installer then no partitions were found." Exit "Quit the installer" $partmenu`
- if [ "$TARGETPART" = "Exit" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
- exit 1
- fi
- HOMEINST=`echo $PARTINST | sed -r "s/$SWAP//" | sed -r "s/$TARGETPART//"`
- for i in $HOMEINST; do
- homepart="$i"
- homepartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
- homepartmenu="$homepartmenu $homepart $homepartsize"
- done
- HOMEPART=`$DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select a partition to install /home to. If the only option you see is root then no extra partitions were found." root "put /home on the root partition" $homepartmenu`
- #check mode and get new user info if it is a dist mode
- testmode=`grep "1000" /etc/passwd | grep -v "Live"`
- if [ "$testmode" = "" ]; then
- #root password entry section
- TARGETROOTPASS="1"
- TARGETROOTPASS2="2"
- while [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; do
- TARGETROOTPASS=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root."`
- TARGETROOTPASS2=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root again."`
- if [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again."
- fi
- done
- #username input secton
- TARGETUSERFULLNAME=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new user's real name to be setup on the installed system."`
- TARGETUSER=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new username to be setup on the installed system. Must be in lowercase letters only."`
- #make sure its all lowercase just in case
- TARGETUSER="`echo $TARGETUSER | awk '{print tolower ($0)}'`"
- #password entry section
- TARGETPASS="1"
- TARGETPASS2="2"
- while [ "$TARGETPASS" != "$TARGETPASS2" ]; do
- TARGETPASS=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER."`
- TARGETPASS2=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER again."`
- if [ "$TARGETPASS" != "$TARGETPASS2" ]; then
- $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again."
- fi
- done
- fi
- #hostname setup
- TARGETHOSTNAME=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the hostname for the installed system."`
- #grub location
- GRUBLOCTEST=`$DIALOG $TITLE"$TITLETEXT" $MENU $TEXT"\nPlease select where to install grub to.\n" mbr "Master Boot Record of first drive" root "Root partition - safe choice if you use a different boot manager"`
- if [ "$GRUBLOCTEST" = "root" ]; then
- GRUBLOCTEXT="root partition of $TARGETPART"
- GRUBLOC="root"
- else
- GRUBLOCTEXT="master boot record"
- GRUBLOC=""
- fi
- xterm -e dpkg-reconfigure tzdata
- if [ "$1" = "intl" ]; then
- xterm -e $SETLOCALE
- xterm -e $SETCONSOLEDATA
- xterm -e $SETXSERVER
- fi
- if [ "$HOMEPART" != "root" ]; then
- HOMETEXT=", $HOMEPART will be formatted ext3 for /home "
- fi
- if [ "$testmode" = "" ]; then
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"Please verify that this information is correct.\nNew user $TARGETUSER will be created on the ext3 formatted $TARGETPART partition$HOMETEXT and grub will be installed to the $GRUBLOCTEXT.\n\nDo you want to continue?"
- if [ $? != 0 ]; then
- exit 0
- fi
- else
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"Please verify that this information is correct.\nYour backup mode system will be installed on ext3 formatted $TARGETPART partition$HOMETEXT and grub will be installed to the $GRUBLOCTEXT.\n\nDo you want to continue?"
- if [ $? != 0 ]; then
- exit 0
- fi
- fi
- #END GUI MODE
- fi
- #
- #
- #
- #install_to_hd section
- #
- #
- #
- if [ "$GUI" != "" ]; then
- progressbar "Setting up SWAP Now...Please Wait \n" &
- fi
- #make the filesystem and mount the partition on /TARGET
- if [ "`mount | grep $TARGETPART`" ]; then
- echo "Unmounting the partition we are going to use and format now"
- umount /dev/$TARGETPART
- fi
- sleep 2
- echo "Preparing swap partition now"
- mkswap /dev/$SWAP
- swapon /dev/$SWAP
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- if [ "$GUI" != "" ]; then
- progressbar "Formatting $TARGETPART Now...Please Wait \n" &
- fi
- echo "Formatting the $TARGETPART partition now"
- mke2fs -j /dev/$TARGETPART
- mkdir -p /TARGET
- sleep 2
- echo "Mounting the TARGET partition now"
- mount /dev/$TARGETPART /TARGET -o rw
- sleep 2
- echo "Using tune2fs to prevent the forced checks on boot"
- tune2fs -c 0 -i 0 /dev/$TARGETPART
- rm -rf /TARGET/lost+found
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- if [ "$HOMEPART" != "root" ]; then
- if [ "$GUI" != "" ]; then
- progressbar "Formatting $HOME Now...Please Wait \n" &
- fi
- echo "Formatting the $HOME partition now"
- mkdir -p /TARGET/home
- mke2fs -j /dev/$HOMEPART
- echo "Mounting the TARGET home partition now"
- mount /dev/$HOMEPART /TARGET/home -o rw
- tune2fs -c 0 -i 0 /dev/$HOMEPART
- rm -rf /TARGET/home/lost+found
- TARGETHOMEUUID=`vol_id -u /dev/$HOMEPART`
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- fi
- TARGETPARTUUID=`vol_id -u /dev/$TARGETPART`
- TARGETSWAPUUID=`vol_id -u /dev/$SWAP`
- #get the cdrom device for fstab
- TARGETCDROM=`cat /proc/mounts | grep "/live/image" | awk '{print $1}'`
- sleep 1
- if [ "$GUI" != "" ]; then
- progressbar "Copying the files to the TARGET System...Please Wait \n" &
- fi
- # copy the live system to the hd
- echo "Copying the live system to the hard drive now."
- echo "This may take a while so please wait until completed."
- rsync -a / /TARGET --exclude=/{TARGET,live,cdrom,mnt,proc,sys,media}
- mkdir -p /TARGET/{proc,mnt,sys,media/cdrom}
- echo "Completed copying the files."
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- if [ "$GUI" != "" ]; then
- progressbar "Performing post-install steps now...Please Wait\n" &
- fi
- echo "Performing post-install steps now"
- #prepare the chroot environment for some post install changes
- mount -o bind /proc /TARGET/proc
- mount -o bind /dev /TARGET/dev
- rm -rf /TARGET/etc/fstab
- #create the new fstab
- if [ "$HOMEPART" = "root" ]; then
- cat > /TARGET/etc/fstab <<FOO
- # /etc/fstab: static file system information.
- #
- # <file system> <mount point> <type> <options> <dump> <pass>
- proc /proc proc defaults 0 0
- # /dev/$TARGETPART
- UUID=$TARGETPARTUUID / ext3 relatime,errors=remount-ro 0 1
- # /dev/$SWAP
- UUID=$TARGETSWAPUUID none swap sw 0 0
- # cdrom
- $TARGETCDROM /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
- FOO
- else
- cat > /TARGET/etc/fstab <<FOO
- # /etc/fstab: static file system information.
- #
- # <file system> <mount point> <type> <options> <dump> <pass>
- proc /proc proc defaults 0 0
- # /dev/$TARGETPART
- UUID=$TARGETPARTUUID / ext3 relatime,errors=remount-ro 0 1
- # /dev/$HOMEPART home
- UUID=$TARGETHOMEUUID /home ext3 relatime 0 0
- # /dev/$SWAP
- UUID=$TARGETSWAPUUID none swap sw 0 0
- # cdrom
- $TARGETCDROM /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
- FOO
- fi
- # remove diverted update-initramfs as live-initramfs makes it a dummy file when booting the livecd
- if [ -f /TARGET/usr/sbin/update-initramfs.distrib ]; then
- rm -f /TARGET/usr/sbin/update-initramfs
- fi
- # remove diverted update-notifier as it is disabled by live-initramfs
- if [ -f /TARGET/usr/lib/update-notifier/apt-check.distrib ]; then
- rm -f /TARGET/usr/lib/update-notifier/apt-check
- fi
- # fix adept_notifier by copying the file we saved when remastersys first ran as live-initramfs removes it
- if [ -f /TARGET/etc/remastersys/adept_notifier_auto.desktop ]; then
- mv /TARGET/etc/remastersys/adept_notifier_auto.desktop /TARGET/usr/share/autostart/adept_notifier_auto.desktop
- fi
- # copy trackerd stuff as live-initramfs disables it
- if [ -f /TARGET/etc/remastersys/tracker-applet.desktop ]; then
- mv /TARGET/etc/remastersys/tracker-applet.desktop /TARGET/etc/xdg/autostart/tracker-applet.desktop
- fi
- if [ -f /TARGET/etc/remastersys/trackerd.desktop.xdg ]; then
- mv /TARGET/etc/remastersys/trackerd.desktop.xdg /TARGET/etc/xdg/autostart/trackerd.desktop
- fi
- if [ -f /TARGET/etc/remastersys/trackerd.desktop.share ]; then
- mv /TARGET/etc/remastersys/trackerd.desktop.share /TARGET/usr/share/autostart/trackerd.desktop
- fi
- #restore original inittab as live-initramfs changes it
- cp /TARGET/usr/share/sysvinit/inittab /TARGET/etc/inittab
- #check if this is a backup livecd or a dist livecd
- if [ "$TARGETUSER" != "" ]; then
- echo "$TARGETHOSTNAME" > /TARGET/etc/hostname
- echo "127.0.0.1 localhost" > /TARGET/etc/hosts
- echo "127.0.0.1 $TARGETHOSTNAME" >> /TARGET/etc/hosts
- touch /TARGET/etc/resolv.conf
- #remove autologin from livecd on installed system
- #gdm section
- if [ -f /TARGET/etc/gdm/gdm.conf ]; then
- sed -i -e 's/AutomaticLogin/#AutomaticLogin/g' /TARGET/etc/gdm/gdm.conf
- sed -i -e 's/TimedLogin/#TimedLogin/g' /TARGET/etc/gdm/gdm.conf
- fi
- #kde3 and kde4 section
- if [ -f /TARGET/etc/default/kdm.d/live-autologin ]; then
- rm -f /TARGET/etc/default/kdm.d/live-autologin
- fi
- if [ -f /TARGET/etc/kde3/kdm/kdmrc ]; then
- sed -i -e 's/AutoLogin/#AutoLogin/g' /TARGET/etc/kde3/kdm/kdmrc
- sed -i -e 's/AutoReLogin/#AutoReLogin/g' /TARGET/etc/kde3/kdm/kdmrc
- fi
- if [ -f /TARGET/etc/kde4/kdm/kdmrc ]; then
- sed -i -e 's/AutoLogin/#AutoLogin/g' /TARGET/etc/kde4/kdm/kdmrc
- sed -i -e 's/AutoReLogin/#AutoReLogin/g' /TARGET/etc/kde4/kdm/kdmrc
- fi
- DEFAULTGROUPS="audio,cdrom,dialout,floppy,video,plugdev,netdev,powerdev"
- cat > /TARGET/bin/tempinstallerscript <<FOO
- #!/bin/bash
- echo -e "$TARGETROOTPASS\n$TARGETROOTPASS\n" | passwd root
- userdel -f -r $USERNAME
- sed -i '/$USERNAME/d' /etc/sudoers
- groupadd -g 1000 $TARGETUSER
- useradd -u 1000 -g 1000 -c "$TARGETUSERFULLNAME,,," -G $DEFAULTGROUPS -s /bin/bash -m $TARGETUSER
- echo -e "$TARGETPASS\n$TARGETPASS\n" | passwd $TARGETUSER
- dpkg-divert --remove --rename --quiet /usr/lib/update-notifier/apt-check
- dpkg-divert --remove --rename --quiet /usr/sbin/update-initramfs
- update-initramfs -t -c -k $(/bin/uname -r)
- shadowconfig on
- FOO
- else
- echo "$TARGETHOSTNAME" > /TARGET/etc/hostname
- echo "127.0.0.1 localhost" > /TARGET/etc/hosts
- echo "127.0.0.1 $TARGETHOSTNAME" >> /TARGET/etc/hosts
- touch /TARGET/etc/resolv.conf
- cat > /TARGET/bin/tempinstallerscript <<FOO
- #!/bin/bash
- dpkg-divert --remove --rename --quiet /usr/lib/update-notifier/apt-check
- dpkg-divert --remove --rename --quiet /usr/sbin/update-initramfs
- update-initramfs -t -c -k $(uname -r)
- FOO
- fi
- chmod 755 /TARGET/bin/tempinstallerscript
- chroot /TARGET /bin/tempinstallerscript
- rm /TARGET/bin/tempinstallerscript
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- if [ "$GUI" != "" ]; then
- progressbar "Installing and setting up grub...Please Wait\n" &
- fi
- echo "Installing and setting up grub."
- # Setup grub
- remastersys-grubconfig /TARGET/boot/grub/menu.lst $GRUBLOC
- echo "Post-install has completed."
- echo
- echo "Unmounting the TARGET partition."
- sleep 1
- umount /TARGET/proc
- sleep 1
- umount /TARGET/dev
- sleep 1
- umount /TARGET
- sleep 1
- if [ "$GUI" != "" ]; then
- killall -KILL tail
- fi
- $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"\n\nInstallation is complete.\n\nIf everything went well you should have your new system installed and ready.\n\nDo you want to reboot now to try it out?" $HEIGHT $WIDTH
- if [ $? != 0 ]; then
- exit 0
- else
- reboot
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement