Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This script will extract, modify and repack a bootable iso image.
  4. #
  5. # Features:
  6. # - Add kickstart file
  7. # - Add post install kickstart scripts
  8. # - Play scripts in a chroot of the filesystem
  9. #
  10. # Dependencies:
  11. # - mkisofs
  12.  
  13. # Initialize our own variables:
  14. output="./output.iso"
  15. workdir="~/.cache/isobuilder"
  16. kickstart=""
  17. postscripts=""
  18. scripts=""
  19.  
  20. function usage {
  21. echo "Usage: $(basename $0) [OPTION]... isofile.iso"
  22. echo " -o output iso file path (default: $output)"
  23. echo " -w working directory used internally "
  24. echo " and cleaned when terminated (default: $workdir)"
  25. echo " -k kickstart file path"
  26. echo " -p post install script to add (can be used multiple times)"
  27. echo " -s script to play in chroot (can be used multiple times)"
  28. echo " -h display help"
  29. }
  30.  
  31. # The variable OPTIND holds the number of options parsed by the last call to getopts
  32. OPTIND=1 # Reset in case getopts has been used previously in the shell.
  33.  
  34. while getopts "o:w:k:p:s:h" opt; do
  35. case "$opt" in
  36. h|\?)
  37. usage
  38. exit 0
  39. ;;
  40. :)
  41. echo "Invalid option: $OPTARG requires an argument"
  42. exit 0
  43. ;;
  44. o) output=$OPTARG
  45. ;;
  46. w) workdir=$OPTARG
  47. ;;
  48. k) kickstart=$OPTARG
  49. ;;
  50. p) postscripts+=("$OPTARG")
  51. ;;
  52. s) scripts+=("$OPTARG")
  53. ;;
  54. esac
  55. done
  56.  
  57. shift $((OPTIND-1))
  58.  
  59. # Ignore -- if existing
  60. [ "${1:-}" = "--" ] && shift
  61.  
  62. # Check positional mandatory arguments
  63. iso=$1
  64. if [ -z "$iso" ]
  65. then
  66. usage
  67. exit 0
  68. fi
  69.  
  70. echo "iso: $iso"
  71. echo "output: $output"
  72. echo "workdir: $workdir"
  73. echo "kickstart: $kickstart"
  74.  
  75. # List scripts
  76. for val in "${scripts[@]}"; do
  77. echo "script: $val"
  78. done
  79.  
  80. # List post scripts
  81. for val in "${postscripts[@]}"; do
  82. echo "postscript: $val"
  83. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement