drop escalate wrapper
This commit is contained in:
parent
53cb23a2c5
commit
9e6fd1988b
|
|
@ -41,25 +41,25 @@ bootstrap() {
|
||||||
bootstrap_tar_unpack ${strapdir}
|
bootstrap_tar_unpack ${strapdir}
|
||||||
else
|
else
|
||||||
# Debootstrap stage 1
|
# Debootstrap stage 1
|
||||||
escalate "root" "debootstrap --foreign --arch ${arch} ${release} ${strapdir} ${mirror}"
|
sudo debootstrap --foreign --arch ${arch} ${release} ${strapdir} ${mirror}
|
||||||
|
|
||||||
# Debootstrap stage 2
|
# Debootstrap stage 2
|
||||||
escalate "root" "chroot ${strapdir} /debootstrap/debootstrap --second-stage"
|
sudo chroot ${strapdir} /debootstrap/debootstrap --second-stage
|
||||||
|
|
||||||
# write all system configuration
|
# write all system configuration
|
||||||
conf_print_debconf | escalate "root" "tee ${strapdir}/debconf.set"
|
conf_print_debconf | sudo tee ${strapdir}/debconf.set
|
||||||
conf_print_fstab | escalate "root" "tee ${strapdir}/etc/fstab"
|
conf_print_fstab | sudo tee ${strapdir}/etc/fstab
|
||||||
conf_print_hostname | escalate "root" "tee ${strapdir}/etc/hostname"
|
conf_print_hostname | sudo tee ${strapdir}/etc/hostname
|
||||||
conf_print_hosts | escalate "root" "tee ${strapdir}/etc/hosts"
|
conf_print_hosts | sudo tee ${strapdir}/etc/hosts
|
||||||
conf_print_networkifaces | escalate "root" "tee ${strapdir}/etc/network/interfaces"
|
conf_print_networkifaces | sudo tee ${strapdir}/etc/network/interfaces
|
||||||
conf_print_resolvconf | escalate "root" "tee ${strapdir}/etc/resolv.conf"
|
conf_print_resolvconf | sudo tee ${strapdir}/etc/resolv.conf
|
||||||
conf_print_sourceslist | escalate "root" "tee ${strapdir}/etc/apt/sources.list"
|
conf_print_sourceslist | sudo tee ${strapdir}/etc/apt/sources.list
|
||||||
|
|
||||||
# write third-stage for chroot
|
# write third-stage for chroot
|
||||||
bootstrap_config_thirdstage | escalate "root" "tee ${strapdir}/thirdstage.sh"
|
bootstrap_config_thirdstage | sudo tee ${strapdir}/thirdstage.sh
|
||||||
bootstrap_config_cleanup | escalate "root" "tee ${strapdir}/cleanup.sh"
|
bootstrap_config_cleanup | sudo tee ${strapdir}/cleanup.sh
|
||||||
escalate "root" "chmod +x ${strapdir}/thirdstage.sh"
|
sudo chmod +x ${strapdir}/thirdstage.sh
|
||||||
escalate "root" "chmod +x ${strapdir}/cleanup.sh"
|
sudo chmod +x ${strapdir}/cleanup.sh
|
||||||
|
|
||||||
# chroot into it and configure further
|
# chroot into it and configure further
|
||||||
# Debootstrap stage 3
|
# Debootstrap stage 3
|
||||||
|
|
@ -68,8 +68,8 @@ bootstrap() {
|
||||||
|
|
||||||
mountdevproc ${strapdir}
|
mountdevproc ${strapdir}
|
||||||
|
|
||||||
escalate "root" "chroot ${strapdir} /thirdstage.sh"
|
sudo chroot ${strapdir} /thirdstage.sh
|
||||||
escalate "root" "chroot ${strapdir} /cleanup.sh"
|
sudo chroot ${strapdir} /cleanup.sh
|
||||||
|
|
||||||
umountdevproc ${strapdir}
|
umountdevproc ${strapdir}
|
||||||
|
|
||||||
|
|
@ -87,6 +87,7 @@ rm -f /debconf.set
|
||||||
rm -f /thirdstage.sh
|
rm -f /thirdstage.sh
|
||||||
rm -f /etc/ssh/*key
|
rm -f /etc/ssh/*key
|
||||||
rm -f /etc/ssh/*.pub
|
rm -f /etc/ssh/*.pub
|
||||||
|
rm -f /root/.bash_history
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,6 +123,8 @@ apt-get --yes --force-yes dist-upgrade
|
||||||
|
|
||||||
apt-get --yes --force-yes autoremove
|
apt-get --yes --force-yes autoremove
|
||||||
|
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
rm -f /usr/sbin/policy-rc.d
|
rm -f /usr/sbin/policy-rc.d
|
||||||
rm -f /usr/sbin/invoke-rc.d
|
rm -f /usr/sbin/invoke-rc.d
|
||||||
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
|
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
|
||||||
|
|
@ -139,9 +142,15 @@ bootstrap_tar_pack() {
|
||||||
act "tarball found already in ::1 dir::" $_dest
|
act "tarball found already in ::1 dir::" $_dest
|
||||||
else
|
else
|
||||||
notice "Creating boostrap tarball in ::1 tgz::" $bootstrap_tgz
|
notice "Creating boostrap tarball in ::1 tgz::" $bootstrap_tgz
|
||||||
|
silly
|
||||||
|
|
||||||
pushd ${strapdir}
|
pushd ${strapdir}
|
||||||
|
|
||||||
mkdir -p ${_dest}
|
mkdir -p ${_dest}
|
||||||
escalate root "tar czf $bootstrap_tgz . --exclude=dev,sys,proc"
|
sudo tar czf $bootstrap_tgz \
|
||||||
|
--exclude={./boot,./dev,./sys,./proc} \
|
||||||
|
./
|
||||||
|
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
ls -lh $bootstrap_tgz
|
ls -lh $bootstrap_tgz
|
||||||
|
|
@ -160,5 +169,7 @@ bootstrap_tar_unpack() {
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p ${unpath}
|
mkdir -p ${unpath}
|
||||||
|
silly
|
||||||
tar xf $bootstrap_tgz -C ${unpath}
|
tar xf $bootstrap_tgz -C ${unpath}
|
||||||
|
sudo mkdir -p ${unpath}/{boot,dev,sys,proc}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,11 @@ escalate() {
|
||||||
|
|
||||||
findloopmapp() {
|
findloopmapp() {
|
||||||
fn findloopmapp
|
fn findloopmapp
|
||||||
req=(imgpath)
|
req=(imgpath imgname workdir)
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
loopdevice=`sudo losetup -f --show ${imgpath}`
|
pushd ${workdir}
|
||||||
|
loopdevice=`sudo losetup -f --show ${imgname}`
|
||||||
mappdevice=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
|
mappdevice=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
|
||||||
func "Loop device: ::1 loopdev::" $loopdevice
|
func "Loop device: ::1 loopdev::" $loopdevice
|
||||||
func "Mapper device: ::1 mappdev::" $mappdevice
|
func "Mapper device: ::1 mappdev::" $mappdevice
|
||||||
|
|
@ -52,6 +53,8 @@ findloopmapp() {
|
||||||
mappdevice="/dev/mapper/${mappdevice}"
|
mappdevice="/dev/mapper/${mappdevice}"
|
||||||
bootpart=${mappdevice}p1
|
bootpart=${mappdevice}p1
|
||||||
rootpart=${mappdevice}p2
|
rootpart=${mappdevice}p2
|
||||||
|
|
||||||
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
mountdevproc() {
|
mountdevproc() {
|
||||||
|
|
@ -60,9 +63,9 @@ mountdevproc() {
|
||||||
req=(mntdir)
|
req=(mntdir)
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
escalate "root" "mount -t proc proc ${mntdir}/proc" && act "mounted /proc"
|
sudo mount -t proc proc ${mntdir}/proc && act "mounted /proc"
|
||||||
escalate "root" "mount -o bind /dev ${mntdir}/dev" && act "mounted /dev"
|
sudo mount -o bind /dev ${mntdir}/dev && act "mounted /dev"
|
||||||
escalate "root" "mount -o bind /dev/pts ${mntdir}/dev/pts" && act "mounted /dev/pts"
|
sudo mount -o bind /dev/pts ${mntdir}/dev/pts && act "mounted /dev/pts"
|
||||||
}
|
}
|
||||||
|
|
||||||
umountdevproc() {
|
umountdevproc() {
|
||||||
|
|
@ -71,9 +74,9 @@ umountdevproc() {
|
||||||
req=(mntdir)
|
req=(mntdir)
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
escalate "root" "umount ${mntdir}/dev/pts" && act "unmounted /dev/pts" && sleep 2
|
sudo umount ${mntdir}/dev/pts && act "unmounted /dev/pts" && sleep 2
|
||||||
escalate "root" "umount ${mntdir}/dev" && act "unmounted /dev" && sleep 2
|
sudo umount ${mntdir}/dev && act "unmounted /dev" && sleep 2
|
||||||
escalate "root" "umount ${mntdir}/proc" && act "unmounted /proc" && sleep 2
|
sudo umount ${mntdir}/proc && act "unmounted /proc" && sleep 2
|
||||||
}
|
}
|
||||||
|
|
||||||
silly() {
|
silly() {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ img_partition_dos() {
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
notice "Partitioning with dos"
|
notice "Partitioning with dos"
|
||||||
|
silly
|
||||||
|
|
||||||
dos_boot_size=(ext2 0 64)
|
dos_boot_size=(ext2 0 64)
|
||||||
dos_root_size=(ext4 64 -1)
|
dos_root_size=(ext4 64 -1)
|
||||||
|
|
@ -71,6 +72,7 @@ img_partition_gpt() {
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
notice "Partitioning with gpt"
|
notice "Partitioning with gpt"
|
||||||
|
silly
|
||||||
|
|
||||||
pushd ${workdir}
|
pushd ${workdir}
|
||||||
|
|
||||||
|
|
@ -106,8 +108,10 @@ img_mount() {
|
||||||
|
|
||||||
mkdir -p ${workdir}/rootp
|
mkdir -p ${workdir}/rootp
|
||||||
|
|
||||||
escalate root "mount ${rootpart} ${workdir}/rootp" && act "mounted root partition"
|
sudo mount ${rootpart} ${workdir}/rootp && act "mounted root partition"
|
||||||
escalate root "mount ${bootpart} ${workdir}/rootp/boot" && act "mounted root partition"
|
sudo mount ${bootpart} ${workdir}/rootp/boot && act "mounted boot partition"
|
||||||
|
|
||||||
|
mountdevproc ${workdir}/rootp
|
||||||
}
|
}
|
||||||
|
|
||||||
img_umount() {
|
img_umount() {
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,24 @@
|
||||||
|
|
||||||
## Default system configuration
|
## Default system configuration
|
||||||
|
|
||||||
conf_install_kernel() {
|
conf_install_grub() {
|
||||||
fn conf_install_kernel
|
fn conf_install_grub $@
|
||||||
req=(arch strapdir)
|
chrootpath="$1"
|
||||||
freq=($strapdir/bin/bash)
|
req=(chrootpath)
|
||||||
ckreq || return 1
|
ckreq || return 1
|
||||||
|
|
||||||
escalate root "chroot $strapdir apt-get install linux-image-$arch"
|
notice "Installing grub-pc"
|
||||||
|
sudo chroot ${chrootpath} apt-get --yes --force-yes install grub-pc
|
||||||
|
}
|
||||||
|
|
||||||
|
conf_install_kernel() {
|
||||||
|
fn conf_install_kernel $@
|
||||||
|
chrootpath="$1"
|
||||||
|
req=(arch chrootpath)
|
||||||
|
ckreq || return 1
|
||||||
|
|
||||||
|
notice "Installing stock kernel (linux-image-$arch)"
|
||||||
|
sudo chroot ${chrootpath} apt-get --yes --force-yes install linux-image-$arch
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_print_debconf() {
|
conf_print_debconf() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue