Cleaning script

move-to-docker
Nicolas Arenas 2024-10-25 11:21:05 +02:00
parent 606d8b2eb3
commit 193872d2ae
1 changed files with 0 additions and 77 deletions

View File

@ -15,83 +15,6 @@ IMAGE_DIR=$DIR/image
DEBOOT_STRAP_URL=http://mirror.raiolanetworks.com/ubuntu/
SUDO_PASSWD=${SUDO_PASSWD:-$(cat $PASSWD_FILE)}
export PASSWD_FILE
## FUNCIONES
function exec_as_sudo () {
cat $PASSWD_FILE | sudo -S "$@"
}
function exec_as_sudo_in_chroot () {
local CHROOT=$1
shift
exec_as_sudo chroot $CHROOT "$@"
}
function umount_in_chroot() {
local CHROOT=$2
local PART=$1
if grep $CHROOT$PART /etc/mtab;
then
echo "Unmounting $PART in chroot $CHROOT"
exec_as_sudo_in_chroot $CHROOT umount $PART
return $?
fi
echo "Mount point $PART not found"
return 0
}
function umount_in_host() {
local PART=$1
if findmnt -M $PART
then
echo "Unmounting $PART"
exec_as_sudo umount $PART
return $?
fi
echo "Mount point $PART not found"
return 0
}
function deploy_script_in_chroot() {
local CHROOT=$1
local SCRIPT=$2
local DESTDIR=$3
mkdir -p $CHROOT/$DESTDIR
cp $SCRIPT $CHROOT/$DESTDIR
chmod +x $CHROOT/$DESTDIR/$SCRIPT
}
function deploy_installer() {
mkdir -p $CHROOT_DIR/usr/local/bin
cp openGnsys-installer.sh $CHROOT_DIR/usr/local/bin
chmod +x $CHROOT_DIR/usr/local/bin/openGnsys-installer.sh
}
if [ -d $CHROOT_DIR ] && [ $CLEAN -eq 1 ];
then
SYS_MOUNT_POINT_CHROOT="/proc /sys /dev/pts /dev"
SYS_MOUNT_POINT="/dev /run"
for i in $SYS_MOUNT_POINT_CHROOT;
do
umount_in_chroot $i $CHROOT_DIR
umount_in_chroot $i $UBUNTU_CHROOT_DIR
done
for i in $SYS_MOUNT_POINT;
do
umount_in_host $CHROOT_DIR$i
umount_in_host $UBUNTU_CHROOT_DIR$i
done
if [ $CLEAN_CHROOT -eq 1 ];
then
exec_as_sudo rm -rf $CHROOT_DIR
exec_as_sudo rm -rf $UBUNTU_CHROOT_DIR
fi
exec_as_sudo rm -rf $DIR/image
exec_as_sudo rm -f $OUTPUT_DIR/ubuntu-from-scratch.iso
fi
mkdir -p $IMAGE_DIR
mkdir -p $CHROOT_DIR
# # Copio el script chroot_setup.sh al directorio chroot