unixwz0r

diskfuncs.sh

Dec 30th, 2014
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. #!/bin/bash
  2. #-------------------------------------------------------------------------------
  3. #Created by Gary Perreault mailto: tuxhatlinuxdistro[at]gmail[dot]com
  4. #inspired by script that was created by user helmuthdu & Vincent0ne-
  5. #mailto: helmuthdu[at]gmail[dot]com
  6. #Contribution: flexiondotorg
  7. #mailto: Vincent[at]gmail[dot]com
  8. #-------------------------------------------------------------------------------
  9. #This program is free software: you can redistribute it and/or modify
  10. #it under the terms of the GNU General Public License as published by
  11. #the Free Software Foundation, either version 3 of the License, or
  12. #(at your option) any later version.
  13. #
  14. #This program is distributed in the hope that it will be useful,
  15. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. #GNU General Public License for more details.
  18. #
  19. #You should have received a copy of the GNU General Public License
  20. #along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #-------------------------------------------------------------------------------
  22. # Run this script after your first boot with archlinux (as root)
  23. #--------------------------------------------------------------------------------
  24. # Explaination of the Script: this is the script disk functions for the
  25. # arch-setup installer script.
  26. # Keep it simple!
  27. # What you see, is what you get!
  28. PS3="$prompt1"
  29. TMP=/tmp/tmp.$$
  30. TMP2=/tmp/tmp2.$$
  31. SELECTEDDSK="No Disk Selected: $DEV$DISK"
  32.  
  33. SelectDisk() { #{{{
  34.  
  35. print_line
  36. echo "Available Disks on Computer"
  37. echo
  38. lsblk | grep disk > $TMP
  39. printf "%-10s \t %-10s\n" 'Available Disk' 'Total Size'
  40. print_dbline
  41. awk '{printf "%-17s %-10s\n", $1, $4}' $TMP
  42. print_line
  43. echo
  44. echo "sda usually means whole disk so no partition"
  45. echo "number is required"
  46. echo
  47. echo "There is no need to put /dev on front as it is"
  48. echo "a default directory."
  49. echo
  50. echo -n "What Disk do you want to use: "
  51. read DISK
  52. echo "You selected $DEV$DISK"
  53. TASK1="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  54. echo
  55. rm $TMP
  56. pause_function
  57.  
  58. } #}}}}
  59.  
  60. PartitionDisks() { #{{{
  61.  
  62. if [ "$DISK" != "NULL" ]
  63. then
  64. echo "What partition program to use on $DEV$DISK"
  65. echo
  66. echo "F - Fdisk"
  67. echo "C - Cfdisk"
  68. echo "P - Parted"
  69. echo
  70. print_askopt
  71. read PARTPROG
  72.  
  73. case $PARTPROG in
  74. F|f)
  75. fdisk $DEV$DISK
  76. TASK2="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  77. ;;
  78. C|c)
  79. cfdisk $DEV$DISK
  80. TASK2="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  81. ;;
  82. P|p)
  83. parted $DEV$DISK
  84. TASK2="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  85. ;;
  86.  
  87. esac
  88. else
  89. echo "No Disk is Selected, please select one"
  90. sleep 5
  91.  
  92. fi
  93. pause_function
  94. } #}}}
  95.  
  96.  
  97. format_drive () {
  98.  
  99. # Shows the Selected Disk and Partition
  100. lsblk | grep $Disk
  101.  
  102. }
  103.  
  104. cpisoskeltohd() {
  105. echo ""
  106. echo "${Green}Copying ISO Skel to HDD"
  107. time (cp -ax /{home,root} /mnt)
  108. cp -avr /opt /mnt
  109. TASK4="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  110.  
  111.  
  112. }
  113.  
  114.  
  115. install_bootloader() {
  116.  
  117. syslinux-install_update -iam
  118. cp -v $SLCFGFILE $SLCFGFILE.orig
  119. cp -v $CVSPLASH /boot/syslinux
  120. sleep 1
  121. selectsyslinuxcfg
  122.  
  123. }
  124.  
  125. selectsyslinuxcfg(){
  126.  
  127. ROOTDSK=`df / | sed '1d' | awk '{print $1}'`
  128. print_title0
  129. local cfgfiles=(`cat $SLTXT | sed 's/\/.*$//' | uniq`);
  130. print_line
  131. echo "${Bold}${Red}Select Syslinux cfg file that is right for your root disk${Reset}"
  132. print_line
  133. select SLCFG in "${cfgfiles[@]}"
  134. do
  135. if contains_element "$SLCFG" "${cfgfiles[@]}"
  136. then
  137. echo "cp -v $SLFILES/$SLCFG $SYSLINUXCFG"
  138. cp -v $SLFILES/$SLCFG $SLCFGFILE
  139. echo ""
  140. break
  141. else
  142. invalid_option
  143. fi
  144. done
  145.  
  146. }
  147.  
  148. network_interface(){
  149. ip link show
  150. pause_function
  151. read -p "dhcp-interface: " dhcpif
  152. dhcpif=`echo $dhcpif | tr '[:upper:]' '[:lower:]'`
  153. systemctl enable dhcpcd@${dhcpif}.service
  154. systemctl start dhcpcd@${dhcpif}.service
  155.  
  156. }
  157.  
  158. formatrootpart() {
  159.  
  160. if [ "$DISK" != "NULL" ]
  161. then
  162. print_line
  163. lsblk |grep $DISK
  164. print_line
  165. echo
  166. echo "You can select the Non Swap partition as the chosen"
  167. echo "root drive, usually the 1st partition"
  168. echo
  169. echo -n "Partition name without the /dev: "
  170. read ROOTDISK
  171. print_line
  172. echo 1. Ext2
  173. echo 2. Ext3
  174. echo 3. Ext4
  175. echo 4. ReiserFS
  176. echo
  177. print_askopt
  178. read FSOPT
  179. case $FSOPT in
  180. 1)
  181. mkfs.ext2 $DEV$ROOTDISK
  182. ;;
  183. 2)
  184. mkfs.ext3 $DEV$ROOTDISK
  185. ;;
  186. 3)
  187. mkfs.ext4 $DEV$ROOTDISK
  188. ;;
  189. 4)
  190. mkfs.reiserfs $DEV$ROOTDISK
  191. ;;
  192. esac
  193.  
  194.  
  195. TASK3="${Bold}${White}[${Bold}${Green}X${Bold}${White}] is Set"
  196. echo Mounting $DEV$ROOTDISK to $MNT
  197. mount $DEV$ROOTDISK $MNT
  198. sleep 10
  199. else
  200. echo "You must select a disk"
  201. sleep 1
  202. fi
  203.  
  204. }
Advertisement
Add Comment
Please, Sign In to add comment