Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script will extract, modify and repack a bootable iso image.
- #
- # Features:
- # - Add kickstart file
- # - Add post install kickstart scripts
- # - Play scripts in a chroot of the filesystem
- #
- # Dependencies:
- # - mkisofs
- # Initialize our own variables:
- output="./output.iso"
- workdir="~/.cache/isobuilder"
- kickstart=""
- postscripts=""
- scripts=""
- function usage {
- echo "Usage: $(basename $0) [OPTION]... isofile.iso"
- echo " -o output iso file path (default: $output)"
- echo " -w working directory used internally "
- echo " and cleaned when terminated (default: $workdir)"
- echo " -k kickstart file path"
- echo " -p post install script to add (can be used multiple times)"
- echo " -s script to play in chroot (can be used multiple times)"
- echo " -h display help"
- }
- # The variable OPTIND holds the number of options parsed by the last call to getopts
- OPTIND=1 # Reset in case getopts has been used previously in the shell.
- while getopts "o:w:k:p:s:h" opt; do
- case "$opt" in
- h|\?)
- usage
- exit 0
- ;;
- :)
- echo "Invalid option: $OPTARG requires an argument"
- exit 0
- ;;
- o) output=$OPTARG
- ;;
- w) workdir=$OPTARG
- ;;
- k) kickstart=$OPTARG
- ;;
- p) postscripts+=("$OPTARG")
- ;;
- s) scripts+=("$OPTARG")
- ;;
- esac
- done
- shift $((OPTIND-1))
- # Ignore -- if existing
- [ "${1:-}" = "--" ] && shift
- # Check positional mandatory arguments
- iso=$1
- if [ -z "$iso" ]
- then
- usage
- exit 0
- fi
- echo "iso: $iso"
- echo "output: $output"
- echo "workdir: $workdir"
- echo "kickstart: $kickstart"
- # List scripts
- for val in "${scripts[@]}"; do
- echo "script: $val"
- done
- # List post scripts
- for val in "${postscripts[@]}"; do
- echo "postscript: $val"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement