Skip to content

Instantly share code, notes, and snippets.

@Brawl345
Last active August 23, 2017 13:18
Show Gist options
  • Save Brawl345/9170984 to your computer and use it in GitHub Desktop.
Save Brawl345/9170984 to your computer and use it in GitHub Desktop.
mountiso
#!/bin/bash
# adds arch repo to pacman.conf
# released under the GPLv3
# root check begin
try_sudo=1
if [[ $1 = --no-sudo ]]
then
try_sudo=0
shift
else
uid="$(id -u 2>/dev/null)" || try_sudo=0
[[ $uid = 0 ]] && try_sudo=0
fi
if ((try_sudo))
then
sudo "$0" --no-sudo "$@"
exit $?
fi
# root check end
while (true); do
echo -n "Name of the repo? "
read REPO
echo -n "SigLevel (if any)? "
read SIGLEVEL
echo -n "Server URL? "
read SERVER
echo -n "Key-ID (if any)? "
read KEYID
echo "The following will be added to your /etc/pacman.conf:"
echo ""
echo "[$REPO]"
[[ ! -z "$SIGLEVEL" ]] && echo "SigLevel = $SIGLEVEL"
echo "Server = $SERVER"
echo -ne "\n > Is this correct? [y/n]: "
read ANTWORT
if [[ $ANTWORT == "y" ]]; then
break;
fi
done
echo "Writing to /etc/pacman.conf..."
echo "" >> /etc/pacman.conf
echo "[$REPO]" >> /etc/pacman.conf
[[ ! -z "$SIGLEVEL" ]] && echo "SigLevel = $SIGLEVEL" >> /etc/pacman.conf
echo "Server = $SERVER" >> /etc/pacman.conf
if [[ ! -z "$KEY" ]]; then
echo "Importing key $KEY..."
pacman-key -r $KEY
echo "Signing key $KEY locally..."
pacman-key --lsign $KEY
fi
echo "Updating repositories..."
pacman -Sy
exit 0
#!/bin/bash
#
# Copyright (c) 2005 by dejot <Josef Behr>
# Modified for ISO13346(UDF) Images by overlord8k8 (ubuntuusers)
# Distributed under the GPL version 2
#
# mountiso - Mount iso9660/ISO13346(UDF)-Images into directoy
## Das Verzeichnis, in das gemounted wird. !! Schreibrechte benötigt !!
mountdir="/media/$USER" ## Bei "/media/" erscheint das Image auf dem Desktop)
# root check begin
try_sudo=1
if [[ $1 = --no-sudo ]]
then
try_sudo=0
shift
else
uid="$(id -u 2>/dev/null)" || try_sudo=0
[[ $uid = 0 ]] && try_sudo=0
fi
if ((try_sudo))
then
sudo "$0" --no-sudo "$@"
exit $?
fi
# root check end
if [ ! -d $mountdir ]; then
echo "Verzeichnis $mountdir/ existiert nicht. Ich erstelle es..."
mkdir $mountdir
fi
if [ "$1" = "" ]; then
echo "Benutzung:"
echo "mountiso name-des-images"
echo "Du findest die .iso dann in $mountdir/name-des-images/"
elif [ "$1" = "-u" ]; then
if [ "$2" = "" ]; then
echo "Kein Image zum umounten..."
echo ""
echo "Benutzung:"
echo "mountiso -u name-des-images"
echo "Die .iso muss sich in "$mountdir" befinden!"
else
if [ -d $mountdir/$2 ]; then
sudo umount $mountdir/$2
rmdir $mountdir/$2
echo "Umounten abgeschlossen."
else
echo "Dieses Image wurde nicht in $mountdir gemountet."
fi
fi
else
if [ ! -e "$1" ]; then
echo "Image-Datei nicht gefunden. Abbruch"
else
if [ ! -d $mountdir/$1 ]; then
echo "Erstelle Verzeichnis: $mountdir/$1/"
mkdir $mountdir/$1
echo "Bereit."
fi
echo "Am mounten..."
sudo mount -o loop -t auto $1 $mountdir/$1
echo "Wenn keine Fehler angezeigt wurden, wurde das Image erfolgreich gemountet. (Ausnahme: read-only)"
echo "Du findest es in $mountdir/$1/, bzw. auf dem Desktop"
fi
fi
#!/bin/bash
#
# Copyright (c) 2005 by dejot <Josef Behr>
# Modified for ISO13346(UDF) Images by overlord8k8 (ubuntuusers)
# German Translation by iCON (WiiDatabase)
# Distributed under the GPL version 2
#
# mountiso - Mount iso9660/ISO13346(UDF)-Images into directoy
## Das Verzeichnis, in das gemounted wird. !! Schreibrechte benötigt !!
mountdir="/run/media/$USER" ## Bei "/run/media/" erscheint das Image auf dem Desktop)
# root check begin
try_sudo=1
if [[ $1 = --no-sudo ]]
then
try_sudo=0
shift
else
uid="$(id -u 2>/dev/null)" || try_sudo=0
[[ $uid = 0 ]] && try_sudo=0
fi
if ((try_sudo))
then
sudo "$0" --no-sudo "$@"
exit $?
fi
# root check end
if [ ! -d $mountdir ]; then
echo "Verzeichnis $mountdir/ existiert nicht. Ich erstelle es..."
mkdir $mountdir
fi
if [ "$1" = "" ]; then
echo "Benutzung:"
echo "mountiso name-des-images"
echo "mountiso -u name-des-images"
echo "Du findest die .iso dann in $mountdir/name-des-images/"
elif [ "$1" = "-u" ]; then
if [ "$2" = "" ]; then
echo "Kein Image zum umounten..."
echo ""
echo "Benutzung:"
echo "mountiso -u name-des-images"
echo "Die .iso muss sich in "$mountdir" befinden!"
else
if [ -d $mountdir/$2 ]; then
sudo umount $mountdir/$2
rmdir $mountdir/$2
echo "Umounten abgeschlossen."
else
echo "Dieses Image wurde nicht in $mountdir gemountet."
fi
fi
else
if [ ! -e "$1" ]; then
echo "Image-Datei nicht gefunden. Abbruch"
else
if [ ! -d $mountdir/$1 ]; then
echo "Erstelle Verzeichnis: $mountdir/$1/"
mkdir $mountdir/$1
echo "Bereit."
fi
echo "Am mounten..."
sudo mount -o loop -t auto $1 $mountdir/$1
echo "Wenn keine Fehler angezeigt wurden, wurde das Image erfolgreich gemountet. (Ausnahme: read-only)"
echo "Du findest es in $mountdir/$1/, bzw. auf dem Desktop"
fi
fi
#!/bin/bash
#
# Copyright (c) 2005 by dejot <Josef Behr>
# Modified for ISO13346(UDF) Images by overlord8k8 (ubuntuusers)
# German Translation by iCON (WiiDatabase)
# Distributed under the GPL version 2
#
# mountiso - Mount iso9660/ISO13346(UDF)-Images into directoy
mountdir="/run/media/$USER"
# root check begin
try_sudo=1
if [[ $1 = --no-sudo ]]
then
try_sudo=0
shift
else
uid="$(id -u 2>/dev/null)" || try_sudo=0
[[ $uid = 0 ]] && try_sudo=0
fi
if ((try_sudo))
then
sudo "$0" --no-sudo "$@"
exit $?
fi
# root check end
if [ ! -d $mountdir ]; then
echo "Verzeichnis $mountdir/ existiert nicht. Ich erstelle es..."
mkdir $mountdir
fi
if [ "$1" = "" ]; then
echo "Benutzung:"
echo "mountiso name-des-images"
echo "mountiso -u name-des-images"
echo "Du findest die .iso dann in $mountdir/name-des-images/"
elif [ "$1" = "-u" ]; then
if [ "$2" = "" ]; then
echo "Kein Image zum umounten..."
echo ""
echo "Benutzung:"
echo "mountiso -u name-des-images"
echo "Die .iso muss sich in "$mountdir" befinden!"
else
if [ -d $mountdir/$2 ]; then
sudo umount $mountdir/$2
rmdir $mountdir/$2
echo "Umounten abgeschlossen."
else
echo "Dieses Image wurde nicht in $mountdir gemountet."
fi
fi
else
if [ ! -e "$1" ]; then
echo "Image-Datei nicht gefunden. Abbruch"
else
if [ ! -d $mountdir/$1 ]; then
echo "Erstelle Verzeichnis: $mountdir/$1/"
mkdir $mountdir/$1
echo "Bereit."
fi
echo "Am mounten..."
sudo mount -o loop -t auto $1 $mountdir/$1
echo "Wenn keine Fehler angezeigt wurden, wurde das Image erfolgreich gemountet. (Ausnahme: read-only)"
echo "Du findest es in $mountdir/$1/, bzw. auf dem Desktop"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment