update license info and description; separate old and unstable scripts

This commit is contained in:
2015-07-07 16:04:28 +03:00
parent b89ae2d245
commit 60139ed8b8
6 changed files with 103 additions and 58 deletions

119
old_scripts/mnt-part-to-nas.sh Executable file
View File

@@ -0,0 +1,119 @@
#!/bin/bash
########################################################################
# Copyright (C) 2013 Max Mehl <mail@mehl.mx>
########################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
#
# This is a script to mount Windows/SMB shared drives via the CLI
# It's a bit more advanced than mnt-share.sh but still very basic and
# was used for a special environment.
# It requires pcmanfm and smbfs/cifs-utils to be installed.
#
########################################################################
cd "$(dirname "$(readlink -f "$0")")"
# Test if config.cfg exists and set needed variables
if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
source config.cfg
## FUNKTIONEN
# Überprüft, ob Root-Rechte am Start sind
function rootcheck {
if [ $EUID -ne 0 ]; then
echo "Dieses Script benötigt Root-Rechte. Rechte erlangen mit \"su\" oder \"sudo -i\"."
exit 1
fi
}
# Möglichkeit, Variablen zu ändern
function varcheck {
echo "Folgende Parameter sind vorgegeben:"
echo "Adresse des Zielortes: $NASPATH"
echo "User für Zielort, falls nötig (sonst leer): $NASUSER"
echo "Passwort für Zielort, falls nötig (sonst leer): $NASPASS"
read -p "Sollen diese so übernommen werden? [y/n]: " YN
if [ "$YN" = "y" ]; then
echo "Daten wurden akzeptiert. Fahre fort..."
elif [ "$YN" = "n" ]; then
echo "Nun gewünschte Daten für Zielort eingeben:"
read -p "Adresse des Zielortes: " NASPATH
read -p "User für Zielort, falls nötig (sonst leer): " NASUSER
read -p "Passwort für Zielort, falls nötig (sonst leer): " NASPASS
echo "Daten wurden übernommen. Fahre fort..."
else
echo "Ungültige Eingabe. Script wird beendet."
exit 1
fi
unset YN
}
# Mounte Zielverzeichnis
function nasmount {
if ! ([ "$NASUSER" = "" ] && [ "$NASPASS" = "" ]); then
OPT="-o user=$NASUSER,password=$NASPASS"
fi
if [ ! -e /mnt/nas ]; then
mkdir -p /mnt/nas
fi
mount -t cifs //$NASPATH /mnt/nas $OPT
}
# Fragt Namen des Kunden ab und erstellt Verzeichnis wenn nötig
function destcheck {
read -p "Name des Kunden: " NAME
if [ ! -e /mnt/nas/$NAME ]; then
mkdir /mnt/nas/$NAME
fi
}
# Frage zu sichernde Partition ab
function partmount {
fdisk -l
YN="y"
while [ "$YN" = "y" ]; do
read -p "Welche NTFS-Partition soll gemountet werden? [z.B /dev/sda1]: " PART
if [ ! -e $PART ]; then
echo "Partition nicht vorhanden, bitte zu mountende Partition auswählen!"
else
if [ ! -e /mnt$PART ]; then
mkdir -p /mnt$PART
fi
mount -t ntfs-3g $PART /mnt$PART -o force
pcmanfm /mnt$PART /mnt/nas/$KUNDE &
fi
read -p "Noch eine Partition mounten? y für Ja, beliebige Taste zum Abbrechen: " YN
done
unset YN
}
## START DES PROGRAMMS
rootcheck
if [ "$1" = "unmount" ]; then
umount /mnt/nas /mnt/dev/*
echo "/mnt/nas und /mnt/dev/* wurden ausgehängt. Beende."
exit 1
fi
varcheck
nasmount
destcheck
partmount

View File

@@ -0,0 +1,8 @@
1. Datei von NAS auf lokal herunterladen
2. RM auf Datei, Eigenschaften, Berechtigungen, Datei als Programm ausführen
3. Im Dateimanager zu lokaler Datei navigieren und F4 drücken --> Terminal an dieser Stelle wird geöffnet
4. "su" eingeben für Root-Rechte
5. ./mountscript.sh --> Anweisungen folgen
Zum Unmounten aller Partitionen + NAS:
./mountscript.sh unmount

89
old_scripts/mnt-share.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
########################################################################
# Copyright (C) 2013 Max Mehl <mail@mehl.mx>
########################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
#
# This is a script to mount Windows/SMB shared drives via the CLI
# It is very basic and was used for a special environment.
# It requires pcmanfm and smbfs/cifs-utils to be installed.
#
########################################################################
cd "$(dirname "$(readlink -f "$0")")"
# Test if config.cfg exists and set needed variables
if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
source config.cfg
## FUNKTIONEN
# Überprüft, ob Root-Rechte am Start sind
function rootcheck {
if [ $EUID -ne 0 ]; then
echo "Dieses Script benötigt Root-Rechte. Rechte erlangen mit \"su\" oder \"sudo -i\"."
exit 1
fi
}
# Möglichkeit, Variablen zu ändern
function varcheck {
echo "Folgende Parameter sind vorgegeben:"
echo "Adresse des Zielortes: $NASDIR auf $NASIP"
echo "User für Zielort, falls nötig (sonst leer): $NASUSER"
echo "Passwort für Zielort, falls nötig (sonst leer): $NASPASS"
read -p "Sollen diese so übernommen werden? [y/n]: " YN
if [ "$YN" = "y" ]; then
echo "Daten wurden akzeptiert. Fahre fort..."
elif [ "$YN" = "n" ]; then
echo "Nun gewünschte Daten für Zielort eingeben:"
read -p "Adresse des Zielortes: " NASPATH
read -p "User für Zielort, falls nötig (sonst leer): " NASUSER
read -p "Passwort für Zielort, falls nötig (sonst leer): " NASPASS
echo "Daten wurden übernommen. Fahre fort..."
else
echo "Ungültige Eingabe. Script wird beendet."
exit 1
fi
unset YN
}
# Mounte Zielverzeichnis
function nasmount {
if ! ([ "$NASUSER" = "" ] && [ "$NASPASS" = "" ]); then
OPT="-o user=$NASUSER,password=$NASPASS"
fi
if [ ! -e $LOCALMOUNTDIR/$NASDIR ]; then
mkdir -p $LOCALMOUNTDIR/$NASDIR
fi
mount -t cifs //$NASIP/$NASDIR $LOCALMOUNTDIR/$NASDIR $OPT
}
## START DES PROGRAMMS
#rootcheck
if [ "$1" = "unmount" ]; then
umount /mnt/nas /mnt/dev/*
echo "/mnt/nas und /mnt/dev/* wurden ausgehängt. Beende."
exit 1
fi
varcheck
nasmount

100
old_scripts/mnt-share2.sh Executable file
View File

@@ -0,0 +1,100 @@
#!/bin/bash
########################################################################
# Copyright (C) 2014 Max Mehl <mail@mehl.mx>
########################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################
#
# This is a script to mount Windows/SMB shared drives via a dialogue
# It is very basic and was used for a special environment, however it's
# more clever than mnt-share.sh
# It requires smbfs/cifs-utils to be installed.
#
########################################################################
cd "$(dirname "$(readlink -f "$0")")"
# Test if config.cfg exists and set needed variables
if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
source config.cfg
# Choose preconfigured SHARE to mount
function mount {
if ! SHARE=$(zenity --list \
--height=300 \
--text="Please choose. Cancel to unmount shares." \
--title="Choose Network Share" \
--column "Preconfigured Network Shares" \
${SHAREPATH[*]}); then
unmountquestion # If you press cancel, it should ask you to unmount all drives
fi
# If you double click on an entry, it gives 'server1|server1' as result instead of 'server1'
# This command cuts of everything after |
NUM=$(echo $SHARE | awk -F: '{ print $1 }') # Which Array?
SHARE=$(echo $SHARE | awk -F\| '{ print $1 }' | awk -F: '{ print $2 }')
SHAREDIR=$(echo $SHARE | awk -F/ '{ print $2 }') # Directory to use
# Make a local directory if not available
if [ ! -e "$LOCALMOUNTDIR"/"$SHAREDIR" ]; then
mkdir -p "$LOCALMOUNTDIR"/"$SHAREDIR"
fi
# Command to mount actually
OPT="-o user="${SHAREUSER[$NUM]}",password="${SHAREPASS[$NUM]}""
echo "mount -t cifs //$SHARE $LOCALMOUNTDIR/$SHAREDIR $OPT"
quitquestion # one more share or quit?
}
# Ask if all preconfigured shares should be unmounted
function unmountquestion {
zenity --question --text="Unmount all preconfigured\nnetwork shares now?"
if [ "$?" = "0" ]; then
unmount # unmount function
else
exit 0
fi
}
# Procedure to unmount all preconfigured shares and exit program afterwards
function unmount {
for ((i = 0; i < ${#SHAREPATH[*]}; i++))
do
SHAREDIR=$(echo "${SHAREPATH[$i]}" | awk -F/ '{ print $2 }')
unmount "$LOCALMOUNTDIR"/$SHAREDIR
echo ""${SHAREPATH[$i]}" unmounted."
done
exit 0
}
# Should another network share storage be mounted?
function quitquestion {
zenity --question \
--text="Mount another network share storage?"
if [ "$?" = "1" ]; then
exit 0
fi
}
# Loop for endless mounts until stopped by unmount or unmountquestion
while :
do
mount # mount function
done