freezedry 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. ### FreezeDry ###
  3. # Hand written installer for Freon Linux
  4. # (C) Chris Dorman, 2017 LGPLv2
  5. # Include Freon Linux's config
  6. . /etc/conf.d/main.conf
  7. . /etc/conf.d/status
  8. # Check if script was ran by root
  9. if [ "$(id -u)" != "0" ]; then
  10. echo -e "[$RED Error $NORMAL] This script needs to be executed by root."
  11. exit 1
  12. fi
  13. # Move to root of filesystem
  14. cd /
  15. case $1 in
  16. install)
  17. if [ ! -f "$2" ]; then
  18. echo "Error: $2 doesn't exist. exit."
  19. exit 1
  20. fi
  21. # Include config file
  22. . $2
  23. # Make directories if they don't exist
  24. if [ ! -d "/mnt/inst" ]; then
  25. mkdir /mnt/inst
  26. fi
  27. if [ ! -d "/mnt/target" ]; then
  28. mkdir /mnt/target
  29. fi
  30. # Format device partition
  31. echo -e "[$YELLOW Working $NORMAL] Formatting installation partition"
  32. echo -n "Formatting..."
  33. mkfs.ext2 $DEVPARTITION > /dev/null 2>&1
  34. status
  35. echo -e "[$YELLOW Working $NORMAL] Mounting filesystems for installation"
  36. echo -n "Installation media..."
  37. mount $INSTMEDIA /mnt/inst > /dev/null 2>&1
  38. status
  39. echo -n "Device: $DEVPARTITION..."
  40. mount $DEVPARTITION /mnt/target > /dev/null 2>&1
  41. status
  42. echo -e "[$YELLOW Working $NORMAL] Copying and extracting system files"
  43. echo -n "Copying filesystem..."
  44. cd /mnt/inst
  45. cp boot/rootfs.gz /mnt/target
  46. status
  47. echo -n "Copying Linux kernel..."
  48. mkdir /mnt/target/boot
  49. cp boot/bzImage /mnt/target/boot
  50. status
  51. echo -n "Extracting filesystem..."
  52. cd ../target
  53. zcat rootfs.gz | cpio -id > /dev/null 2>&1
  54. status
  55. echo -n "Removing filesystem archive..."
  56. rm rootfs.gz
  57. status
  58. echo -e "[$YELLOW Working $NORMAL] Installing bootloader to $DEVICE"
  59. echo -n "Executing grub-install..."
  60. grub-install --root-directory=/mnt/target /dev/hda --directory=/lib/grub/i386-pc > /dev/null 2>&1
  61. status
  62. echo -n "Generating makefile..."
  63. echo "#
  64. # /boot/grub/grub.cfg - freon grub2 config file
  65. # Set menu colors
  66. set menu_color_normal=white/blue
  67. set menu_color_highlight=light-blue/white
  68. # Set menu display time
  69. set timeout=10
  70. # Set the default boot entry (first is 0)
  71. set default=0
  72. # Boot entries:
  73. # CRUX
  74. menuentry \"Freon Linux $FREONVERSION\" {
  75. linux /boot/bzImage root=$DEVPARTITION
  76. }
  77. " >> /mnt/target/boot/grub/grub.cfg
  78. status
  79. ;;
  80. config)
  81. case $2 in
  82. *)
  83. echo "### FreezeDry configuration file ###
  84. # Installation media device (Hardware with Freon's system files)
  85. # Examples:
  86. # CDROM: /dev/cdrom
  87. # USB: /dev/sda1
  88. INSTMEDIA=\"/dev/cdrom\"
  89. # Installation device (Hardware used for the Freon installation)
  90. # Example: /dev/hda
  91. DEVICE=\"/dev/hda\"
  92. # Device partition (Used for the Freon installation)
  93. # Example: /dev/hda1: First partition of device hda
  94. DEVPARTITION=\"/dev/hda1\"" >> $2
  95. ;;
  96. esac
  97. ;;
  98. help|*)
  99. echo "FreezeDry: Freon Installer ~ Install Freon Linux to a device"
  100. echo "Usage: "
  101. echo " freezedry install <path to config file>: Install Freon Linux"
  102. echo " freezedry config <path to config> : Create a default config";;
  103. esac
  104. exit 0