Advertisement
Guest User

Untitled

a guest
May 25th, 2010
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.66 KB | None | 0 0
  1. #dummy first line
  2. #!/bin/bash
  3. #
  4. #
  5. # remastersys-installer is an alternative installer for remastered livecd/dvd's
  6. #
  7. #
  8. # Created by Tony "Fragadelic" Brijeski
  9. #
  10. # Copyright 2008,2009 Under the GNU GPL2 License
  11. #
  12. # Originally Created September 12th,2008
  13. #
  14. #
  15. #
  16. #
  17.  
  18. # This script requires either zenity or dialog to run
  19. #
  20.  
  21. # checking to make sure script is running with root privileges
  22.  
  23. testroot="`whoami`"
  24.  
  25. if [ "$testroot" != "root" ]; then
  26. echo " Must be run as root - exiting"
  27. exit 1
  28. fi
  29.  
  30. # set options depending on mode - text or gui
  31.  
  32. testdialog=`which dialog`
  33. DIALOG="`which dialog`"
  34. HEIGHT="17"
  35. WIDTH="50"
  36. MENUHEIGHT="12"
  37. TITLE="--title "
  38. TEXT=""
  39. ENTRY="--inputbox "
  40. MENU="--menu"
  41. YESNO="--yesno "
  42. MSGBOX="--msgbox "
  43. PASSWORD="--passwordbox "
  44. PARTITIONPROG="cfdisk"
  45. TITLETEXT="Remastersys Live Installer"
  46.  
  47. if [ "$1" = "gui" -o "$2" = "gui" ]; then
  48. GUI="$DISPLAY"
  49. fi
  50.  
  51. if [ "$GUI" != "" ]; then
  52.  
  53. testzenity=`which zenity`
  54.  
  55. if [ "$testzenity" = "" ]; then
  56. echo " Zenity not present - proceeding to install zenity"
  57. apt-get -y -q install zenity
  58. testzenity=`which zenity`
  59. fi
  60.  
  61. testgparted=`which gparted`
  62. if [ "$testgparted" = "" ]; then
  63. echo " Gparted not present - proceeding to install gparted"
  64. apt-get -y -q install gparted
  65. fi
  66.  
  67.  
  68. if [ "$testzenity" != "" ]; then
  69. DIALOG="`which zenity` --width=640 --height=400"
  70. TITLE="--title="
  71. TEXT="--text="
  72. ENTRY="--entry "
  73. ENTRYTEXT="--entry-text "
  74. MENU="--list --column=Pick --column=Info"
  75. YESNO="--question "
  76. MSGBOX="--info "
  77. PASSWORD="--entry --hide-text "
  78. testgparted=`which gparted`
  79. if [ "$testgparted" = "" ]; then
  80. PARTITIONPROG="xterm -e cfdisk"
  81. else
  82. PARTITIONPROG="gparted"
  83. fi
  84. TITLETEXT="Remastersys Live Installer"
  85. fi
  86.  
  87.  
  88.  
  89. fi
  90.  
  91. if [ "$DIALOG" = "" ]; then
  92. echo "Cannot find dialog or zenity. Exiting."
  93. exit 1
  94. fi
  95.  
  96. progressbar () {
  97. tail -f /usr/bin/remastersys-installer | $DIALOG $TEXT"$@" --progress --pulsate --auto-close
  98. }
  99.  
  100.  
  101.  
  102. . /etc/live.conf
  103.  
  104. if [ "$1" = "intl" ]; then
  105. SETLOCALE="dpkg-reconfigure locales"
  106. SETCONSOLEDATA="dpkg-reconfigure console-data"
  107. SETXSERVER="dpkg-reconfigure xserver-xorg"
  108. fi
  109.  
  110.  
  111.  
  112.  
  113.  
  114. if [ "$GUI" = "" ]; then
  115.  
  116. #
  117. #TEXT MODE
  118. #
  119. #inform them what this is and ask if they want to continue
  120.  
  121. $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"\n\nThis is an advanced installer.\n\nPlease use with caution.\n\nDo you want to continue?" $HEIGHT $WIDTH
  122.  
  123. if [ $? != 0 ]; then
  124. exit 0
  125. fi
  126.  
  127. $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
  128.  
  129. #choose the drive to partition
  130.  
  131. DRIVES=`cat /proc/partitions | grep -v loop | grep -v major | grep -v "^$" | awk '{ print $4}' | grep -v "[0-9]"`
  132.  
  133. for i in $DRIVES; do
  134. partdrive="$i"
  135. partdrivesize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  136. partdrivemenu="$partdrivemenu $partdrive $partdrivesize"
  137. done
  138.  
  139.  
  140. $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.$$
  141.  
  142. if [ "$?" = "0" ]; then
  143. PARTDRIVE=`cat /tmp/choice.$$`
  144. else
  145. PARTDRIVE="Exit"
  146. fi
  147. rm /tmp/choice.$$
  148.  
  149. if [ "$PARTDRIVE" = "Exit" ]; then
  150. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
  151. exit 1
  152. fi
  153.  
  154. $PARTITIONPROG /dev/$PARTDRIVE
  155.  
  156. #find the swap partition, swapon, and generate the uuid for fstab
  157. TARGETSWAP=`fdisk -l | grep swap | cut -d " " -f1`
  158. TARGETSWAP=`echo $TARGETSWAP | sed -r "s/\/dev\///g"`
  159. for i in $TARGETSWAP; do
  160. swappart="$i"
  161. swappartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  162. swappartmenu="$swappartmenu $swappart $swappartsize"
  163. done
  164.  
  165. $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.$$
  166.  
  167. if [ "$?" = "0" ]; then
  168. SWAP=`cat /tmp/choice.$$`
  169. else
  170. SWAP="Exit"
  171. fi
  172. rm /tmp/choice.$$
  173.  
  174. if [ "$SWAP" = "Exit" ]; then
  175. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
  176. exit 1
  177. fi
  178.  
  179.  
  180. #choose the partition to install to
  181.  
  182. PARTITIONS=`cat /proc/partitions | grep "$PARTDRIVE" | awk '{ print $4}' | grep "[0-9]"`
  183. PARTINSTTEMP=`echo $PARTITIONS | sed -r "s/$SWAP//"`
  184. PARTINST=`echo $PARTINSTTEMP`
  185. for i in $PARTINST; do
  186. tempsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  187. if [ "$tempsize" = "1" ]; then
  188. PARTINST=`echo $PARTINST | sed -r "s/$i//"`
  189. fi
  190. done
  191.  
  192.  
  193.  
  194. for i in $PARTINST; do
  195. part="$i"
  196. partsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  197. partmenu="$partmenu $part $partsize"
  198. done
  199.  
  200.  
  201. $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.$$
  202.  
  203. if [ "$?" = "0" ]; then
  204. TARGETPART=`cat /tmp/choice.$$`
  205. else
  206. TARGETPART="Exit"
  207. fi
  208. rm /tmp/choice.$$
  209.  
  210. if [ "$TARGETPART" = "Exit" ]; then
  211. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now." $HEIGHT $WIDTH
  212. exit 1
  213. fi
  214.  
  215. HOMEINST=`echo $PARTINST | sed -r "s/$SWAP//" | sed -r "s/$TARGETPART//"`
  216.  
  217. for i in $HOMEINST; do
  218. homepart="$i"
  219. homepartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  220. homepartmenu="$homepartmenu $homepart $homepartsize"
  221. done
  222.  
  223. $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.$$
  224.  
  225. if [ "$?" = "0" ]; then
  226. HOMEPART=`cat /tmp/choice.$$`
  227. else
  228. HOMEPART="root"
  229. fi
  230. rm /tmp/choice.$$
  231.  
  232.  
  233.  
  234.  
  235.  
  236. #check mode and get new user info if it is a dist mode
  237. testmode=`grep "1000" /etc/passwd | grep -v "Live"`
  238.  
  239. if [ "$testmode" = "" ]; then
  240.  
  241. #root password entry section
  242. TARGETROOTPASS="1"
  243. TARGETROOTPASS2="2"
  244.  
  245. while [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; do
  246.  
  247. $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root." $HEIGHT $WIDTH 2>/tmp/choice.$$
  248. if [ "$?" = "0" ]; then
  249. TARGETROOTPASS=`cat /tmp/choice.$$`
  250. else
  251. exit 1
  252. fi
  253. rm /tmp/choice.$$
  254. $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root again." $HEIGHT $WIDTH 2>/tmp/choice.$$
  255. if [ "$?" = "0" ]; then
  256. TARGETROOTPASS2=`cat /tmp/choice.$$`
  257. else
  258. exit 1
  259. fi
  260. rm /tmp/choice.$$
  261.  
  262. if [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; then
  263. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again." $HEIGHT $WIDTH
  264. fi
  265.  
  266. done
  267.  
  268. rm /tmp/choice.$$
  269.  
  270. #username input secton
  271.  
  272. $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.$$
  273. if [ "$?" = "0" ]; then
  274. TARGETUSERFULLNAME=`cat /tmp/choice.$$`
  275. else
  276. exit 1
  277. fi
  278. rm /tmp/choice.$$
  279.  
  280.  
  281. $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.$$
  282. if [ "$?" = "0" ]; then
  283. TARGETUSER=`cat /tmp/choice.$$`
  284. else
  285. exit 1
  286. fi
  287. rm /tmp/choice.$$
  288.  
  289.  
  290. #make sure its all lowercase just in case
  291. TARGETUSER="`echo $TARGETUSER | awk '{print tolower ($0)}'`"
  292.  
  293.  
  294. #password entry section
  295.  
  296. TARGETPASS="1"
  297. TARGETPASS2="2"
  298.  
  299. while [ "$TARGETPASS" != "$TARGETPASS2" ]; do
  300.  
  301. $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER." $HEIGHT $WIDTH 2>/tmp/choice.$$
  302. if [ "$?" = "0" ]; then
  303. TARGETPASS=`cat /tmp/choice.$$`
  304. else
  305. exit 1
  306. fi
  307. rm /tmp/choice.$$
  308. $DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER again." $HEIGHT $WIDTH 2>/tmp/choice.$$
  309. if [ "$?" = "0" ]; then
  310. TARGETPASS2=`cat /tmp/choice.$$`
  311. else
  312. exit 1
  313. fi
  314. rm /tmp/choice.$$
  315.  
  316. if [ "$TARGETPASS" != "$TARGETPASS2" ]; then
  317. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again." $HEIGHT $WIDTH
  318. fi
  319.  
  320. done
  321.  
  322. rm /tmp/choice.$$
  323.  
  324. fi
  325.  
  326.  
  327. #hostname setup
  328. $DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the hostname for the installed system." $HEIGHT $WIDTH 2>/tmp/choice.$$
  329. if [ "$?" = "0" ]; then
  330. TARGETHOSTNAME=`cat /tmp/choice.$$`
  331. else
  332. exit 1
  333. fi
  334. rm /tmp/choice.$$
  335.  
  336.  
  337. #grub location
  338. $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.$$
  339.  
  340. if [ "$?" = "0" ]; then
  341. GRUBLOCTEST=`cat /tmp/choice.$$`
  342. fi
  343. rm /tmp/choice.$$
  344.  
  345. if [ "$GRUBLOCTEST" = "root" ]; then
  346. GRUBLOCTEXT="root partition of $TARGETPART"
  347. GRUBLOC="root"
  348. else
  349. GRUBLOCTEXT="master boot record"
  350. GRUBLOC=""
  351. fi
  352.  
  353. dpkg-reconfigure tzdata
  354. $SETLOCALE
  355. $SETCONSOLEDATA
  356. $SETXSERVER
  357.  
  358. if [ "$HOMEPART" != "root" ]; then
  359. HOMETEXT=", $HOMEPART will be formatted ext3 for /home "
  360. fi
  361.  
  362. if [ "$testmode" = "" ]; then
  363. $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
  364. if [ $? != 0 ]; then
  365. exit 0
  366. fi
  367. else
  368. $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
  369. if [ $? != 0 ]; then
  370. exit 0
  371. fi
  372. fi
  373.  
  374. #END TEXT MODE
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381. else
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388. #
  389. #GUI MODE
  390. #
  391. #inform them what this is and ask if they want to continue
  392.  
  393. $DIALOG $TITLE"$TITLETEXT" $YESNO $TEXT"\n\nThis is an advanced installer.\n\nPlease use with caution.\n\nDo you want to continue?"
  394.  
  395. if [ $? != 0 ]; then
  396. exit 0
  397. fi
  398.  
  399. $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."
  400.  
  401. #choose the drive to partition
  402.  
  403. DRIVES=`cat /proc/partitions | grep -v loop | grep -v major | grep -v "^$" | awk '{ print $4}' | grep -v "[0-9]"`
  404. j="0"
  405. for i in $DRIVES; do
  406. partdrive="$i"
  407. partdrivesize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  408. partdrivemenu="$partdrivemenu $partdrive $partdrivesize"
  409. done
  410.  
  411.  
  412. 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`
  413.  
  414.  
  415. if [ "$PARTDRIVE" = "Exit" ]; then
  416. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
  417. exit 1
  418. fi
  419.  
  420. $PARTITIONPROG /dev/$PARTDRIVE
  421.  
  422. #find the swap partition, swapon, and generate the uuid for fstab
  423. #find the swap partition, swapon, and generate the uuid for fstab
  424. TARGETSWAP=`fdisk -l | grep swap | cut -d " " -f1`
  425. TARGETSWAP=`echo $TARGETSWAP | sed -r "s/\/dev\///g"`
  426. for i in $TARGETSWAP; do
  427. swappart="$i"
  428. swappartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  429. swappartmenu="$swappartmenu $swappart $swappartsize"
  430. done
  431.  
  432. 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`
  433.  
  434.  
  435. if [ "$SWAP" = "Exit" ]; then
  436. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
  437. exit 1
  438. fi
  439.  
  440.  
  441. #choose the partition to install to
  442.  
  443. PARTITIONS=`cat /proc/partitions | grep "$PARTDRIVE" | awk '{ print $4}' | grep "[0-9]"`
  444. PARTINSTTEMP=`echo $PARTITIONS | sed -r "s/$SWAP//"`
  445. PARTINST=`echo $PARTINSTTEMP`
  446. for i in $PARTINST; do
  447. tempsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  448. if [ "$tempsize" = "1" ]; then
  449. PARTINST=`echo $PARTINST | sed -r "s/$i//"`
  450. fi
  451. done
  452.  
  453.  
  454. for i in $PARTINST; do
  455. part="$i"
  456. partsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  457. partmenu="$partmenu $part $partsize"
  458. done
  459.  
  460.  
  461. 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`
  462.  
  463. if [ "$TARGETPART" = "Exit" ]; then
  464. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"\n\nQuiting the installer now."
  465. exit 1
  466. fi
  467.  
  468. HOMEINST=`echo $PARTINST | sed -r "s/$SWAP//" | sed -r "s/$TARGETPART//"`
  469. for i in $HOMEINST; do
  470. homepart="$i"
  471. homepartsize=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
  472. homepartmenu="$homepartmenu $homepart $homepartsize"
  473. done
  474.  
  475. 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`
  476.  
  477.  
  478. #check mode and get new user info if it is a dist mode
  479. testmode=`grep "1000" /etc/passwd | grep -v "Live"`
  480.  
  481. if [ "$testmode" = "" ]; then
  482.  
  483. #root password entry section
  484. TARGETROOTPASS="1"
  485. TARGETROOTPASS2="2"
  486.  
  487. while [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; do
  488.  
  489. TARGETROOTPASS=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root."`
  490. TARGETROOTPASS2=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for root again."`
  491.  
  492. if [ "$TARGETROOTPASS" != "$TARGETROOTPASS2" ]; then
  493. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again."
  494. fi
  495.  
  496. done
  497.  
  498. #username input secton
  499.  
  500. TARGETUSERFULLNAME=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new user's real name to be setup on the installed system."`
  501.  
  502. TARGETUSER=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the new username to be setup on the installed system. Must be in lowercase letters only."`
  503.  
  504. #make sure its all lowercase just in case
  505. TARGETUSER="`echo $TARGETUSER | awk '{print tolower ($0)}'`"
  506.  
  507.  
  508. #password entry section
  509.  
  510. TARGETPASS="1"
  511. TARGETPASS2="2"
  512.  
  513. while [ "$TARGETPASS" != "$TARGETPASS2" ]; do
  514.  
  515. TARGETPASS=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER."`
  516. TARGETPASS2=`$DIALOG $TITLE"$TITLETEXT" $PASSWORD $TEXT"Please enter the password for $TARGETUSER again."`
  517.  
  518. if [ "$TARGETPASS" != "$TARGETPASS2" ]; then
  519. $DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"Passwords do not match. Lets try again."
  520. fi
  521.  
  522. done
  523.  
  524.  
  525. fi
  526.  
  527.  
  528. #hostname setup
  529. TARGETHOSTNAME=`$DIALOG $TITLE"$TITLETEXT" $ENTRY $TEXT"Please enter the hostname for the installed system."`
  530.  
  531.  
  532. #grub location
  533. 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"`
  534.  
  535. if [ "$GRUBLOCTEST" = "root" ]; then
  536. GRUBLOCTEXT="root partition of $TARGETPART"
  537. GRUBLOC="root"
  538. else
  539. GRUBLOCTEXT="master boot record"
  540. GRUBLOC=""
  541. fi
  542.  
  543. xterm -e dpkg-reconfigure tzdata
  544. if [ "$1" = "intl" ]; then
  545. xterm -e $SETLOCALE
  546. xterm -e $SETCONSOLEDATA
  547. xterm -e $SETXSERVER
  548. fi
  549.  
  550. if [ "$HOMEPART" != "root" ]; then
  551. HOMETEXT=", $HOMEPART will be formatted ext3 for /home "
  552. fi
  553.  
  554.  
  555. if [ "$testmode" = "" ]; then
  556. $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?"
  557. if [ $? != 0 ]; then
  558. exit 0
  559. fi
  560. else
  561. $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?"
  562. if [ $? != 0 ]; then
  563. exit 0
  564. fi
  565. fi
  566.  
  567.  
  568. #END GUI MODE
  569.  
  570.  
  571.  
  572.  
  573. fi
  574.  
  575.  
  576.  
  577.  
  578.  
  579. #
  580. #
  581. #
  582. #install_to_hd section
  583. #
  584. #
  585. #
  586. if [ "$GUI" != "" ]; then
  587. progressbar "Setting up SWAP Now...Please Wait \n" &
  588. fi
  589. #make the filesystem and mount the partition on /TARGET
  590. if [ "`mount | grep $TARGETPART`" ]; then
  591. echo "Unmounting the partition we are going to use and format now"
  592. umount /dev/$TARGETPART
  593. fi
  594. sleep 2
  595. echo "Preparing swap partition now"
  596. mkswap /dev/$SWAP
  597. swapon /dev/$SWAP
  598. if [ "$GUI" != "" ]; then
  599. killall -KILL tail
  600. fi
  601. if [ "$GUI" != "" ]; then
  602. progressbar "Formatting $TARGETPART Now...Please Wait \n" &
  603. fi
  604. echo "Formatting the $TARGETPART partition now"
  605. mke2fs -j /dev/$TARGETPART
  606. mkdir -p /TARGET
  607. sleep 2
  608. echo "Mounting the TARGET partition now"
  609. mount /dev/$TARGETPART /TARGET -o rw
  610. sleep 2
  611. echo "Using tune2fs to prevent the forced checks on boot"
  612. tune2fs -c 0 -i 0 /dev/$TARGETPART
  613. rm -rf /TARGET/lost+found
  614. if [ "$GUI" != "" ]; then
  615. killall -KILL tail
  616. fi
  617. if [ "$HOMEPART" != "root" ]; then
  618. if [ "$GUI" != "" ]; then
  619. progressbar "Formatting $HOME Now...Please Wait \n" &
  620. fi
  621. echo "Formatting the $HOME partition now"
  622. mkdir -p /TARGET/home
  623. mke2fs -j /dev/$HOMEPART
  624. echo "Mounting the TARGET home partition now"
  625. mount /dev/$HOMEPART /TARGET/home -o rw
  626. tune2fs -c 0 -i 0 /dev/$HOMEPART
  627. rm -rf /TARGET/home/lost+found
  628. TARGETHOMEUUID=`vol_id -u /dev/$HOMEPART`
  629. if [ "$GUI" != "" ]; then
  630. killall -KILL tail
  631. fi
  632. fi
  633. TARGETPARTUUID=`vol_id -u /dev/$TARGETPART`
  634. TARGETSWAPUUID=`vol_id -u /dev/$SWAP`
  635.  
  636. #get the cdrom device for fstab
  637. TARGETCDROM=`cat /proc/mounts | grep "/live/image" | awk '{print $1}'`
  638.  
  639. sleep 1
  640. if [ "$GUI" != "" ]; then
  641. progressbar "Copying the files to the TARGET System...Please Wait \n" &
  642. fi
  643. # copy the live system to the hd
  644. echo "Copying the live system to the hard drive now."
  645. echo "This may take a while so please wait until completed."
  646.  
  647. rsync -a / /TARGET --exclude=/{TARGET,live,cdrom,mnt,proc,sys,media}
  648.  
  649. mkdir -p /TARGET/{proc,mnt,sys,media/cdrom}
  650.  
  651. echo "Completed copying the files."
  652. if [ "$GUI" != "" ]; then
  653. killall -KILL tail
  654. fi
  655. if [ "$GUI" != "" ]; then
  656. progressbar "Performing post-install steps now...Please Wait\n" &
  657. fi
  658. echo "Performing post-install steps now"
  659.  
  660. #prepare the chroot environment for some post install changes
  661. mount -o bind /proc /TARGET/proc
  662. mount -o bind /dev /TARGET/dev
  663. rm -rf /TARGET/etc/fstab
  664.  
  665. #create the new fstab
  666. if [ "$HOMEPART" = "root" ]; then
  667. cat > /TARGET/etc/fstab <<FOO
  668. # /etc/fstab: static file system information.
  669. #
  670. # <file system> <mount point> <type> <options> <dump> <pass>
  671.  
  672. proc /proc proc defaults 0 0
  673. # /dev/$TARGETPART
  674. UUID=$TARGETPARTUUID / ext3 relatime,errors=remount-ro 0 1
  675. # /dev/$SWAP
  676. UUID=$TARGETSWAPUUID none swap sw 0 0
  677. # cdrom
  678. $TARGETCDROM /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
  679.  
  680. FOO
  681.  
  682. else
  683.  
  684. cat > /TARGET/etc/fstab <<FOO
  685. # /etc/fstab: static file system information.
  686. #
  687. # <file system> <mount point> <type> <options> <dump> <pass>
  688.  
  689. proc /proc proc defaults 0 0
  690. # /dev/$TARGETPART
  691. UUID=$TARGETPARTUUID / ext3 relatime,errors=remount-ro 0 1
  692. # /dev/$HOMEPART home
  693. UUID=$TARGETHOMEUUID /home ext3 relatime 0 0
  694. # /dev/$SWAP
  695. UUID=$TARGETSWAPUUID none swap sw 0 0
  696. # cdrom
  697. $TARGETCDROM /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
  698.  
  699. FOO
  700.  
  701. fi
  702.  
  703.  
  704. # remove diverted update-initramfs as live-initramfs makes it a dummy file when booting the livecd
  705. if [ -f /TARGET/usr/sbin/update-initramfs.distrib ]; then
  706. rm -f /TARGET/usr/sbin/update-initramfs
  707. fi
  708.  
  709. # remove diverted update-notifier as it is disabled by live-initramfs
  710. if [ -f /TARGET/usr/lib/update-notifier/apt-check.distrib ]; then
  711. rm -f /TARGET/usr/lib/update-notifier/apt-check
  712. fi
  713.  
  714. # fix adept_notifier by copying the file we saved when remastersys first ran as live-initramfs removes it
  715. if [ -f /TARGET/etc/remastersys/adept_notifier_auto.desktop ]; then
  716. mv /TARGET/etc/remastersys/adept_notifier_auto.desktop /TARGET/usr/share/autostart/adept_notifier_auto.desktop
  717. fi
  718.  
  719. # copy trackerd stuff as live-initramfs disables it
  720. if [ -f /TARGET/etc/remastersys/tracker-applet.desktop ]; then
  721. mv /TARGET/etc/remastersys/tracker-applet.desktop /TARGET/etc/xdg/autostart/tracker-applet.desktop
  722. fi
  723. if [ -f /TARGET/etc/remastersys/trackerd.desktop.xdg ]; then
  724. mv /TARGET/etc/remastersys/trackerd.desktop.xdg /TARGET/etc/xdg/autostart/trackerd.desktop
  725. fi
  726. if [ -f /TARGET/etc/remastersys/trackerd.desktop.share ]; then
  727. mv /TARGET/etc/remastersys/trackerd.desktop.share /TARGET/usr/share/autostart/trackerd.desktop
  728. fi
  729.  
  730. #restore original inittab as live-initramfs changes it
  731. cp /TARGET/usr/share/sysvinit/inittab /TARGET/etc/inittab
  732.  
  733. #check if this is a backup livecd or a dist livecd
  734. if [ "$TARGETUSER" != "" ]; then
  735.  
  736. echo "$TARGETHOSTNAME" > /TARGET/etc/hostname
  737. echo "127.0.0.1 localhost" > /TARGET/etc/hosts
  738. echo "127.0.0.1 $TARGETHOSTNAME" >> /TARGET/etc/hosts
  739. touch /TARGET/etc/resolv.conf
  740.  
  741. #remove autologin from livecd on installed system
  742.  
  743. #gdm section
  744. if [ -f /TARGET/etc/gdm/gdm.conf ]; then
  745. sed -i -e 's/AutomaticLogin/#AutomaticLogin/g' /TARGET/etc/gdm/gdm.conf
  746. sed -i -e 's/TimedLogin/#TimedLogin/g' /TARGET/etc/gdm/gdm.conf
  747. fi
  748.  
  749. #kde3 and kde4 section
  750. if [ -f /TARGET/etc/default/kdm.d/live-autologin ]; then
  751. rm -f /TARGET/etc/default/kdm.d/live-autologin
  752. fi
  753. if [ -f /TARGET/etc/kde3/kdm/kdmrc ]; then
  754. sed -i -e 's/AutoLogin/#AutoLogin/g' /TARGET/etc/kde3/kdm/kdmrc
  755. sed -i -e 's/AutoReLogin/#AutoReLogin/g' /TARGET/etc/kde3/kdm/kdmrc
  756. fi
  757. if [ -f /TARGET/etc/kde4/kdm/kdmrc ]; then
  758. sed -i -e 's/AutoLogin/#AutoLogin/g' /TARGET/etc/kde4/kdm/kdmrc
  759. sed -i -e 's/AutoReLogin/#AutoReLogin/g' /TARGET/etc/kde4/kdm/kdmrc
  760. fi
  761.  
  762.  
  763. DEFAULTGROUPS="audio,cdrom,dialout,floppy,video,plugdev,netdev,powerdev"
  764.  
  765. cat > /TARGET/bin/tempinstallerscript <<FOO
  766. #!/bin/bash
  767.  
  768. echo -e "$TARGETROOTPASS\n$TARGETROOTPASS\n" | passwd root
  769. userdel -f -r $USERNAME
  770. sed -i '/$USERNAME/d' /etc/sudoers
  771. groupadd -g 1000 $TARGETUSER
  772. useradd -u 1000 -g 1000 -c "$TARGETUSERFULLNAME,,," -G $DEFAULTGROUPS -s /bin/bash -m $TARGETUSER
  773. echo -e "$TARGETPASS\n$TARGETPASS\n" | passwd $TARGETUSER
  774. dpkg-divert --remove --rename --quiet /usr/lib/update-notifier/apt-check
  775. dpkg-divert --remove --rename --quiet /usr/sbin/update-initramfs
  776. update-initramfs -t -c -k $(/bin/uname -r)
  777. shadowconfig on
  778.  
  779. FOO
  780.  
  781.  
  782. else
  783.  
  784. echo "$TARGETHOSTNAME" > /TARGET/etc/hostname
  785. echo "127.0.0.1 localhost" > /TARGET/etc/hosts
  786. echo "127.0.0.1 $TARGETHOSTNAME" >> /TARGET/etc/hosts
  787. touch /TARGET/etc/resolv.conf
  788.  
  789.  
  790. cat > /TARGET/bin/tempinstallerscript <<FOO
  791. #!/bin/bash
  792.  
  793. dpkg-divert --remove --rename --quiet /usr/lib/update-notifier/apt-check
  794. dpkg-divert --remove --rename --quiet /usr/sbin/update-initramfs
  795. update-initramfs -t -c -k $(uname -r)
  796.  
  797. FOO
  798.  
  799.  
  800. fi
  801.  
  802. chmod 755 /TARGET/bin/tempinstallerscript
  803. chroot /TARGET /bin/tempinstallerscript
  804. rm /TARGET/bin/tempinstallerscript
  805. if [ "$GUI" != "" ]; then
  806. killall -KILL tail
  807. fi
  808. if [ "$GUI" != "" ]; then
  809. progressbar "Installing and setting up grub...Please Wait\n" &
  810. fi
  811. echo "Installing and setting up grub."
  812. # Setup grub
  813. remastersys-grubconfig /TARGET/boot/grub/menu.lst $GRUBLOC
  814.  
  815.  
  816. echo "Post-install has completed."
  817. echo
  818. echo "Unmounting the TARGET partition."
  819. sleep 1
  820. umount /TARGET/proc
  821. sleep 1
  822. umount /TARGET/dev
  823. sleep 1
  824. umount /TARGET
  825. sleep 1
  826.  
  827. if [ "$GUI" != "" ]; then
  828. killall -KILL tail
  829. fi
  830.  
  831.  
  832. $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
  833.  
  834. if [ $? != 0 ]; then
  835. exit 0
  836. else
  837. reboot
  838. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement