-
Notifications
You must be signed in to change notification settings - Fork 8
/
remaster-extract
executable file
·94 lines (86 loc) · 2.46 KB
/
remaster-extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
## remaster-extract
## Copyright (C) 2019-2020 Richard Nelson <[email protected]>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
############################
# Dependencies
############################
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ ! -e /usr/bin/rsync ]; then
echo "No /usr/bin/rsync file found!"
echo "Exiting ..."
echo "On Debian based systems, rsync can be installed with:"
echo " apt install rsync"
exit 1
fi
# Source in config
echo "Loading remaster-iso.conf ..."
if [ -f remaster-iso.conf ]; then
echo "Found ./remaster-iso.conf"
echo "Sourcing in ./remaster-iso.conf"
. remaster-iso.conf
elif [ -f /usr/share/remaster-iso/remaster-iso.conf ]; then
echo "Found /usr/share/remaster-iso/remaster-iso.conf"
echo "Sourcing in /usr/share/remaster-iso/remaster-iso.conf"
. /usr/share/remaster-iso/remaster-iso.conf
else
echo "No remaster-iso.conf file found!"
echo "Exiting ..."
exit 1
fi
############################
# Main Code
############################
echo "Conf says remaster-iso version is ${_VER}"
# Set some values for remaster
_ISOSentry=0
while [ -n "$1" ]; do # while loop starts
case "$1" in
-i | --iso)
shift
echo "--iso option was passed of $1"
_ISOName=$1
_ISOSentry=1
;;
--usage)
echo
echo "################## remaster-extract parameters ##################"
echo " -i || --iso - iso to use for extract operation"
echo
exit 0
;;
*) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c
esac
shift
done
if [ "$_ISOSentry" = "1" ]; then
echo "I: ISO was passed starting ..."
if [ -f "${_ISOName}" ]; then
echo "I: Found iso of ${_ISOName}"
mkdir -p $_ISOMountPoint
echo "I: Making iso extract path of ${_ISOExtractPath} "
mkdir -p $_ISOExtractPath
echo "I: Mounting iso on ${_ISOMountPoint} "
mount -o loop "${_ISOName}" ${_ISOMountPoint}
echo "I: Syncing ${_ISOMountPoint} to ${_ISOExtractPath} "
rsync -av ${_ISOMountPoint}/ ${_ISOExtractPath}/
echo "I: Unmounting iso ${_ISOMountPoint} "
umount -l ${_ISOMountPoint}
echo "I: ISO extract is completed"
echo "I: You should be ready to run remaster-squashfs-editor"
else
echo "No ${_ISOName} file found!"
echo "Exiting ..."
exit 1
fi
else
echo "E: No ISO name was passed please see --usage."
exit
fi
exit 0