summaryrefslogtreecommitdiffstats
path: root/ship/src/remaster_arch_shack_installstick
blob: 364e195817c2d5ad8f762235783006ea6c4859ff (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#@include core
#@include iso
#@mainifyme

## TODO: provide a parameter which defines what to be done in the new iso root
set -efu
isofile="${1:-archlinux-2013.06.01-dual.iso}"
outfile="$(basename "${isofile%.iso}".krebs.iso)"
info "outfile will be at $outfile"
bdir="${bdir:-$HOME/build/arch}"
isodir="$bdir/iso"
isomnt="$bdir/isomount"
rootdir="$bdir/root"
outdir="$bdir/out"
echo "$outdir/$outfile"
auto_url=euer.krebsco.de/arch_autoinstall
info "bdir is at $bdir"
[ ! -e "$isofile" ] && die "$isofile does not exist."
arch_label="$(get_volid "$isofile")"
info "Arch iso label is ${arch_label}"
esudo "$@"

#punani install genisoimage


info "cleanup root dir"
rm -rf $bdir
mkdir -p $isomnt $rootdir 
info "mounting isofile ($isofile)"
if is_root;then
    mount -t iso9660 -o loop,ro "$isofile" "$isomnt"
else
    die 'we are not root enough to mount the iso.'
fi
defer "info 'unmounting $isomnt';umount \"$isomnt\""

info "copying from '$isomnt' to '$isodir'"
cp -a "$isomnt" "$isodir"
defer "info 'removing $isodir';rm -rf $isodir"

info "extracting root-image squashfs"


for arch in x86_64 i686;do
    info "unpacking $isomnt/arch/$arch/root-image.fs.sfs"
    mkdir -p "$outdir/$arch"
    defer "info 'removing $outdir/$arch';rm -rf $outdir/$arch"
    mkdir -p "$rootdir/$arch"
    defer "info 'removing $rootdir/$arch';rm -rf $rootdir/$arch"
    unsquashfs -f -d "$outdir/$arch" "$isodir/arch/$arch/root-image.fs.sfs"

    mount "$outdir/$arch/root-image.fs" "$rootdir/$arch"
    defer "info 'unmounting $rootdir/$arch';umount $rootdir/$arch||info 'not mounted'"

    info "Starting of the rootdir verkrepelung"
    # do the magic here
    arch-chroot "$rootdir/$arch" <<EOF
    cat >> /root/.zshrc<<EOL
cat << EOD
This is the Krebs Autoinstaller, we will do all the right things.
Just Wait until everything finished.

- Make sure that RJ45 is connected
- you can bail out of the progress at any time with CTRL-C
- if anything went wrong,you can run the installer again at:
    /krebs/autoinstall

EOD
/krebs/autoinstall
EOL
    mkdir /krebs
    cat > /krebs/autoinstall <<EOL
internet() { ping -w 1 google.de >/dev/null 2>&1; }
while ! internet;do
  echo "no Internet yet, waiting ..."
  sleep 3
done

echo "Grabbing current version of install-script from $auto_url"
echo
echo "AGENTS ARE GOOOOOOOOOOO!"
curl $auto_url 2>/dev/null | sh
EOL
chmod 755 /krebs/autoinstall
EOF
    info "deleting old squashfs"
    rm "$isodir/arch/$arch/root-image.fs.sfs"
    info "creating squashfs at $isodir/arch/$arch/root-image.fs.sfs"
    umount "$rootdir/$arch"
    mksquashfs  "$outdir/$arch/root-image.fs" "$isodir/arch/$arch/root-image.fs.sfs" 
done

info "creating Iso Image"
#genisoimage -l -r -J -V "ARCH_$(date +%Y%m)" \
#    -b isolinux/isolinux.bin -no-emul-boot \
#    -boot-load-size 4 -boot-info-table -c isolinux/boot.cat \
#    -o "$outdir/$outfile" "$isodir" 
rm -f "${outdir}/${outfile}"
xorriso -as mkisofs \
    -iso-level 3 \
    -full-iso9660-filenames \
    -volid "$arch_label" \
    -appid "Shackspace Krebs Installer" \
    -publisher "Shackspace/Krebs" \
    -preparer "prepared by krebs" \
    -eltorito-boot isolinux/isolinux.bin \
    -eltorito-catalog isolinux/boot.cat \
    -no-emul-boot -boot-load-size 4 -boot-info-table \
    -isohybrid-mbr "${isomnt}/isolinux/isohdpfx.bin" \
    -output "${outdir}/${outfile}" \
    "$isodir"