Skip to content

Instantly share code, notes, and snippets.

@crashangelbr
Created August 19, 2018 16:36
Show Gist options
  • Save crashangelbr/eee865acac800a078cef3191a1bfc39b to your computer and use it in GitHub Desktop.
Save crashangelbr/eee865acac800a078cef3191a1bfc39b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Debian offline repository mounting or unmounting script.
# By:~ www.pcsuggest.com
# check for root access
if [ $(id -u) -ne 0 ];then
echo 'run this scripts as root user or use sudo'
exit 1
fi
# create mount points
mkdir -p /media/repo_1
mkdir -p /media/repo_2
mkdir -p /media/repo_3
# mount or unmount
case "$1" in
mount)
# mount Debian DVD ISO images
# must change the path of ISO files according to yours
if $(mountpoint -q /media/repo_1);then
echo 'ISO file already mounted'
else
echo 'mounting ISO file 1'
mount -o loop /home/$USER/debian-9.5.0-amd64-DVD-1.iso /media/repo_1/
fi
if $(mountpoint -q /media/repo_2);then
echo 'ISO file already mounted'
else
echo 'mounting ISO file 2'
mount -o loop /home/$USER/debian-9.5.0-amd64-DVD-2.iso /media/repo_2/
fi
if $(mountpoint -q /media/repo_3);then
echo 'ISO file already mounted'
else
echo 'mounting ISO file 3'
mount -o loop /home/$USER/debian-9.5.0-amd64-DVD-3.iso /media/repo_3/
fi
;;
umount)
# unmount ISO images
if ! $(mountpoint -q /media/repo_1/);then
echo 'repo 1 not mounted'
else umount /media/repo_1
fi
if ! $(mountpoint -q /media/repo_2/);then
echo 'repo 2 not mounted'
else umount /media/repo_2
fi
if ! $(mountpoint -q /media/repo_3/);then
echo 'repo 3 not mounted'
else umount /media/repo_3
fi
;;
*)
echo 'use sudo mount_CD_repo mount/umount to mount or unmount ISO files'
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment