nilmbuntu/extractiso.sh

45 lines
990 B
Bash
Raw Permalink Normal View History

2013-08-17 22:28:49 -04:00
#!/bin/bash
# build the iso
. config || exit 0
if [ "$1" != "ok" ]; then
if [ -e ${ISO} ] || [ -e ${FS} ]; then
echo "remove \"${ISO}\" and \"${FS}\" dirs first,"
echo "or pass \"ok\" as an argument to remove them"
exit 0
fi
fi
set -x
set -e
# download it if it doesn't exist
if ! [ -e ${ORIG} ] ; then
2013-08-18 23:57:37 -04:00
mkdir -p $(dirname ${ORIG})
if [ -e $(dirname ${ORIG})/../$(basename ${ORIG}) ] ; then
# grab from parent directory
cp $(dirname ${ORIG})/../$(basename ${ORIG}) ${ORIG}
else
# grab from web
wget -O "${ORIG}" "${ORIGURL}"
fi
2013-08-17 22:28:49 -04:00
fi
# mount it
sudo umount ${MNT} || true
sudo rm -rf ${MNT} ${ISO} ${FS}
sudo mkdir ${MNT}
sudo mount -o loop,ro "$ORIG" ${MNT}
# copy data
sudo mkdir ${ISO}
sudo rsync --exclude=/casper/filesystem.squashfs -a ${MNT}/ ${ISO}
sudo chown -R ${NONPRIV_UID} ${ISO}
2013-08-17 22:28:49 -04:00
chmod -R u+w ${ISO}
# copy squashfs
sudo unsquashfs -d ${FS} ${MNT}/casper/filesystem.squashfs
sudo umount ${MNT}