-
Notifications
You must be signed in to change notification settings - Fork 3
/
remaster
executable file
·69 lines (53 loc) · 1.6 KB
/
remaster
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
#!/bin/bash
# Programas necesarios
needed="rsync genisoimage mksquashfs xorriso"
for need in ${needed}; do
if ! which ${need} ; then
echo "Se necesita el programa ${need}"
exit 1
fi
done
if [ ! -w / ]; then
echo "Correr como root"
exit 1
fi
iso="${1}"
if [ -z "${iso}" ]; then
echo "Pasar una ISO como argumento"
exit 1
fi
umount filesystem
umount tmp
mkdir -p tmp filesystem jail iso archives
mount -o loop "${iso}" tmp/
mount -o loop tmp/casper/filesystem.squashfs filesystem/ || {
echo "No se pudo montar el sistema de archivos squashfs"
exit 1
}
echo "Sincronizando filesystem/ => jail/"
#cp -a filesystem/* jail/
rsync -avHAX --delete-after --progress --human-readable filesystem/ jail/
rsync -avHAX --delete-after --progress --human-readable --exclude="*.squashfs" tmp/ iso/
mount --bind archives jail/var/cache/apt/archives/
umount filesystem tmp
echo "Ahora puede hacer los cambios necesarios en el chroot, cuando salga se creará la ISO"
cp -fv /etc/resolv.conf jail/etc/
shift
mkdir -p jail/root/remaster
cp -rfv $@ files/* jail/root/remaster/
# http://major.io/2014/06/26/install-debian-packages-without-starting-daemons/
echo '#!/bin/sh' >jail/usr/sbin/policy-rc.d
echo 'exit 101' >jail/usr/sbin/policy-rc.d
chmod +x jail/usr/sbin/policy-rc.d
if which systemd-nspawn ; then
systemd-nspawn -D jail /root/remaster/${1##*/}
else
mount -t proc none jail/proc
mount -t sysfs none jail/sys
mount --bind /dev jail/dev
chroot jail/ /root/remaster/${1##*/}
umount jail/proc jail/sys jail/dev
fi
umount jail/var/cache/apt/archives/
rm -fv jail/usr/sbin/policy-rc.d
rm -rf jail/root/remaster