Skriptsammlung: Unterschied zwischen den Versionen
Aus Geekbox Wiki
Felix (Diskussion | Beiträge) |
Felix (Diskussion | Beiträge) |
||
| Zeile 1: | Zeile 1: | ||
| + | ==i3lock mit blur== |
||
| + | <source lang=bash> |
||
| + | #!/bin/bash |
||
| + | |||
| + | # Dependencies: imagemagick, i3lock-color-git, scrot |
||
| + | |||
| + | IMAGE=$(mktemp).png |
||
| + | TEXT="Type password to unlock" |
||
| + | |||
| + | # get path where the script is located |
||
| + | # its used for the lock icon |
||
| + | pushd `dirname $0` > /dev/null |
||
| + | SCRIPTPATH=`pwd` |
||
| + | popd > /dev/null |
||
| + | |||
| + | # l10n support |
||
| + | case $LANG in |
||
| + | fr_* ) TEXT="Entrez votre mot de passe" ;; # Français |
||
| + | es_* ) TEXT="Ingrese su contraseña" ;; # Española |
||
| + | pl_* ) TEXT="Podaj hasło" ;; # Polish |
||
| + | esac |
||
| + | |||
| + | VALUE="60" #brightness value to compare to |
||
| + | scrot $IMAGE |
||
| + | COLOR=`convert $IMAGE -colorspace hsb -resize 1x1 txt:- | sed -E '/.*$/ { |
||
| + | N |
||
| + | s/.*\n.*([0-9]{1,2}[^\.])\.[0-9]+%\)$/\1/ |
||
| + | }'`; |
||
| + | # pixelate: -scale 10% -scale 1000% |
||
| + | if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text |
||
| + | convert $IMAGE -level 0%,100%,0.6 \ |
||
| + | -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \ |
||
| + | -font Liberation-Sans -pointsize 26 -fill black -gravity center \ |
||
| + | -annotate +0+160 "$TEXT" \ |
||
| + | $SCRIPTPATH/lockdark.png -gravity center -composite $IMAGE |
||
| + | PARAM='--textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e \ |
||
| + | --linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 \ |
||
| + | --insidevercolor=ffffff1c --ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c' |
||
| + | else #black |
||
| + | convert $IMAGE -level 0%,100%,0.6 \ |
||
| + | -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \ |
||
| + | -font Liberation-Sans -pointsize 26 -fill white -gravity center \ |
||
| + | -annotate +0+160 "$TEXT" \ |
||
| + | $SCRIPTPATH/lock.png -gravity center -composite $IMAGE |
||
| + | PARAM='--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e \ |
||
| + | --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 \ |
||
| + | --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c' |
||
| + | fi |
||
| + | |||
| + | # try to use a forked version of i3lock with prepared parameters |
||
| + | i3lock $PARAM -i $IMAGE > /dev/null 2>&1 |
||
| + | |||
| + | if [ $? -ne 0 ]; then |
||
| + | # We have failed, lets get back to stock one |
||
| + | i3lock -i $IMAGE |
||
| + | fi |
||
| + | |||
| + | rm $IMAGE |
||
| + | </source> |
||
| + | |||
| + | |||
| + | [https://raw.githubusercontent.com/meskarune/i3lock-fancy/master/lock.png lock.png] |
||
| + | |||
==Nautilus Metadaten== |
==Nautilus Metadaten== |
||
<source lang=python> |
<source lang=python> |
||
Version vom 27. Januar 2016, 12:38 Uhr
Inhaltsverzeichnis
i3lock mit blur
#!/bin/bash
# Dependencies: imagemagick, i3lock-color-git, scrot
IMAGE=$(mktemp).png
TEXT="Type password to unlock"
# get path where the script is located
# its used for the lock icon
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
# l10n support
case $LANG in
fr_* ) TEXT="Entrez votre mot de passe" ;; # Français
es_* ) TEXT="Ingrese su contraseña" ;; # Española
pl_* ) TEXT="Podaj hasło" ;; # Polish
esac
VALUE="60" #brightness value to compare to
scrot $IMAGE
COLOR=`convert $IMAGE -colorspace hsb -resize 1x1 txt:- | sed -E '/.*$/ {
N
s/.*\n.*([0-9]{1,2}[^\.])\.[0-9]+%\)$/\1/
}'`;
# pixelate: -scale 10% -scale 1000%
if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text
convert $IMAGE -level 0%,100%,0.6 \
-filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \
-font Liberation-Sans -pointsize 26 -fill black -gravity center \
-annotate +0+160 "$TEXT" \
$SCRIPTPATH/lockdark.png -gravity center -composite $IMAGE
PARAM='--textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e \
--linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 \
--insidevercolor=ffffff1c --ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c'
else #black
convert $IMAGE -level 0%,100%,0.6 \
-filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5% \
-font Liberation-Sans -pointsize 26 -fill white -gravity center \
-annotate +0+160 "$TEXT" \
$SCRIPTPATH/lock.png -gravity center -composite $IMAGE
PARAM='--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e \
--linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 \
--insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c'
fi
# try to use a forked version of i3lock with prepared parameters
i3lock $PARAM -i $IMAGE > /dev/null 2>&1
if [ $? -ne 0 ]; then
# We have failed, lets get back to stock one
i3lock -i $IMAGE
fi
rm $IMAGE
Nautilus Metadaten
#!/usr/bin/python
import os
import urllib
#import nautilus
from gi.repository import Nautilus, GObject, Gtk, GdkPixbuf
# for id3 support
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MPEGInfo
from mutagen.ogg import OggPage, OggFileType
from mutagen.oggvorbis import OggVorbis, OggVorbisInfo, delete
# for exif support
import pyexiv2
# for reading videos. for future improvement, this can also read mp3!
import kaa.metadata
# for reading image dimensions
import Image
# for reading pdf
try:
from pyPdf import PdfFileReader
except:
pass
class ColumnExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.InfoProvider):
def __init__(self):
pass
def get_columns(self):
return (
Nautilus.Column(name="NautilusPython::title_column",attribute="title",label="Title",description="Song title"),
Nautilus.Column(name="NautilusPython::album_column",attribute="album",label="Album",description="Album"),
Nautilus.Column(name="NautilusPython::artist_column",attribute="artist",label="Artist",description="Artist"),
Nautilus.Column(name="NautilusPython::tracknumber_column",attribute="tracknumber",label="Track",description="Track number"),
Nautilus.Column(name="NautilusPython::genre_column",attribute="genre",label="Genre",description="Genre"),
Nautilus.Column(name="NautilusPython::date_column",attribute="date",label="Date",description="Date"),
Nautilus.Column(name="NautilusPython::bitrate_column",attribute="bitrate",label="Bitrate",description="Audio Bitrate in kilo bits per second"),
Nautilus.Column(name="NautilusPython::samplerate_column",attribute="samplerate",label="Sample rate",description="Sample rate in Hz"),
Nautilus.Column(name="NautilusPython::length_column",attribute="length",label="Length",description="Length of audio"),
Nautilus.Column(name="NautilusPython::exif_datetime_original_column",attribute="exif_datetime_original",label="EXIF Dateshot ",description="Get the photo capture date from EXIF data"),
Nautilus.Column(name="NautilusPython::exif_software_column",attribute="exif_software",label="EXIF Software",description="EXIF - software used to save image"),
Nautilus.Column(name="NautilusPython::exif_flash_column",attribute="exif_flash",label="EXIF flash",description="EXIF - flash mode"),
Nautilus.Column(name="NautilusPython::exif_pixeldimensions_column",attribute="exif_pixeldimensions",label="EXIF Image Size",description="Image size - pixel dimensions as reported by EXIF data"),
Nautilus.Column(name="NautilusPython::pixeldimensions_column",attribute="pixeldimensions",label="Image Size",description="Image/video size - actual pixel dimensions"),
)
def update_file_info(self, file):
# set defaults to blank
file.add_string_attribute('title', '')
file.add_string_attribute('album', '')
file.add_string_attribute('artist', '')
file.add_string_attribute('tracknumber', '')
file.add_string_attribute('genre', '')
file.add_string_attribute('date', '')
file.add_string_attribute('bitrate', '')
file.add_string_attribute('samplerate', '')
file.add_string_attribute('length', '')
file.add_string_attribute('exif_datetime_original', '')
file.add_string_attribute('exif_software', '')
file.add_string_attribute('exif_flash', '')
file.add_string_attribute('exif_pixeldimensions', '')
file.add_string_attribute('pixeldimensions', '')
if file.get_uri_scheme() != 'file':
return
# strip file:// to get absolute path
filename = urllib.unquote(file.get_uri()[7:])
# mp3 handling
if file.is_mime_type('audio/mpeg'):
# attempt to read ID3 tag
try:
audio = EasyID3(filename)try: file.add_string_attribute('title', audio["title"][0])
except: file.add_string_attribute('title', "[n/a]")
try: file.add_string_attribute('album', audio["album"][0])
except: file.add_string_attribute('album', "[n/a]")
try: file.add_string_attribute('artist', audio["artist"][0])
except: file.add_string_attribute('artist', "[n/a]")
try: file.add_string_attribute('tracknumber', audio["tracknumber"][0])
except: file.add_string_attribute('tracknumber', "[n/a]")
try: file.add_string_attribute('genre', audio["genre"][0])
except: file.add_string_attribute('genre', "[n/a]")
try: file.add_string_attribute('date', audio["date"][0])
except: file.add_string_attribute('date', "[n/a]")
except:
# [SabreWolfy] some files have no ID3 tag and will throw this exception:
file.add_string_attribute('title', "[no ID3]")
file.add_string_attribute('album', "[no ID3]")
file.add_string_attribute('artist', "[no ID3]")
file.add_string_attribute('tracknumber', "[no ID3]")
file.add_string_attribute('genre', "[no ID3]")
file.add_string_attribute('date', "[no ID3]")
# try to read MP3 information (bitrate, length, samplerate)
try:
mpfile = open (filename)
mpinfo = MPEGInfo (mpfile)
file.add_string_attribute('bitrate', str(mpinfo.bitrate/1000) + " Kbps")
file.add_string_attribute('samplerate', str(mpinfo.sample_rate) + " Hz")mp3length = "%02i:%02i:%02i" % ((int(mpinfo.length/3600)), (int(mpinfo.length/60%60)), (int(mpinfo.length%60)))
mpfile.close()
file.add_string_attribute('length', mp3length)
except:
file.add_string_attribute('bitrate', "[n/a]")
file.add_string_attribute('length', "[n/a]")
file.add_string_attribute('samplerate', "[n/a]")
try:
mpfile.close()
except: pass
#ogg handling
if file.is_mime_type('audio/ogg'):
# try to read OGG information (bitrate, length)
try:
oggfile = filename
ogginfo = OggVorbis(str(oggfile))
file.add_string_attribute('bitrate', str(ogginfo.info.bitrate/1000) + " kbps")ogglength = "%02i:%02i:%02i" % ((int(ogginfo.info.length/3600)), (int(ogginfo.info.length/60%60)), (int(ogginfo.info.length%60)))
file.add_string_attribute('length', ogglength)
except:
file.add_string_attribute('bitrate', "[n/a]")
file.add_string_attribute('length', "[n/a]")
# image handling
if file.is_mime_type('image/jpeg') or file.is_mime_type('image/png') or file.is_mime_type('image/gif') or file.is_mime_type('image/bmp'):
# EXIF handling routines
try:
metadata = pyexiv2.ImageMetadata(filename)
metadata.read()
exif_datetimeoriginal = metadata['Exif.Photo.DateTimeOriginal']
exif_imagesoftware = metadata['Exif.Image.Software']
exif_photoflash = metadata['Exif.Photo.Flash']
exif_pixelydimension = metadata['Exif.Photo.PixelYDimension']
exif_pixelxdimension = metadata['Exif.Photo.PixelXDimension']
file.add_string_attribute('exif_datetime_original',str(exif_datetimeoriginal.raw_value))
file.add_string_attribute('exif_software',str(exif_imagesoftware.raw_value))
file.add_string_attribute('exif_flash',str(exif_photoflash.raw_value))
file.add_string_attribute('exif_pixeldimensions',str(exif_pixelydimension.raw_value)+'x'+str(exif_pixelxdimension.raw_value))
except:
# no exif data?
file.add_string_attribute('exif_datetime_original',"")
file.add_string_attribute('exif_software',"")
file.add_string_attribute('exif_flash',"")
file.add_string_attribute('exif_pixeldimensions',"")
# try read image info directly
try:
im = Image.open(filename)
file.add_string_attribute('pixeldimensions',str(im.size[0])+'x'+str(im.size[1]))
except:
file.add_string_attribute('pixeldimensions',"[image read error]")
# video/flac handling
if file.is_mime_type('video/x-msvideo') | file.is_mime_type('video/mpeg') | file.is_mime_type('video/x-ms-wmv') | file.is_mime_type('video/mp4') | file.is_mime_type('audio/x-flac') | file.is_mime_type('video/x-flv') | file.is_mime_type('video/x-matroska') | file.is_mime_type('audio/x-wav'):
try:
info=kaa.metadata.parse(filename)
try: file.add_string_attribute('length',"%02i:%02i:%02i" % ((int(info.length/3600)), (int(info.length/60%60)), (int(info.length%60))))
except: file.add_string_attribute('length','[n/a]')
try: file.add_string_attribute('pixeldimensions', str(info.video[0].width) + 'x'+ str(info.video[0].height))
except: file.add_string_attribute('pixeldimensions','[n/a]')
try: file.add_string_attribute('bitrate',str(round(info.audio[0].bitrate/1000)))
except: file.add_string_attribute('bitrate','[n/a]')
try: file.add_string_attribute('samplerate',str(int(info.audio[0].samplerate))+' Hz')
except: file.add_string_attribute('samplerate','[n/a]')
try: file.add_string_attribute('title', info.title)
except: file.add_string_attribute('title', '[n/a]')
try: file.add_string_attribute('artist', info.artist)
except: file.add_string_attribute('artist', '[n/a]')
try: file.add_string_attribute('genre', info.genre)
except: file.add_string_attribute('genre', '[n/a]')
try: file.add_string_attribute('tracknumber',info.trackno)
except: file.add_string_attribute('tracknumber', '[n/a]')
try: file.add_string_attribute('date',info.userdate)
except: file.add_string_attribute('date', '[n/a]')
try: file.add_string_attribute('album',info.album)
except: file.add_string_attribute('album', '[n/a]')
except:
file.add_string_attribute('length','error')
file.add_string_attribute('pixeldimensions','error')
file.add_string_attribute('bitrate','error')
file.add_string_attribute('samplerate','error')
file.add_string_attribute('title','error')
file.add_string_attribute('artist','error')
file.add_string_attribute('genre','error')
file.add_string_attribute('track','error')
file.add_string_attribute('date','error')
file.add_string_attribute('album','error')
# pdf handling
if file.is_mime_type('application/pdf'):
try:
f = open(filename, "rb")
pdf = PdfFileReader(f)
try: file.add_string_attribute('title', pdf.getDocumentInfo().title)
except: file.add_string_attribute('title', "[n/a]")
try: file.add_string_attribute('artist', pdf.getDocumentInfo().author)
except: file.add_string_attribute('artist', "[n/a]")
f.close()
except:
file.add_string_attribute('title', "[no info]")
file.add_string_attribute('artist', "[no info]")
self.get_columns()
Autostart mit Checkboxes
#!/bin/bash
string=$(whiptail --title "Autostart" --checklist \
"Choose startup applications" 17 32 11 \
"firefox" "" ON\
"thunderbird" "" ON \
"amarok" "" ON \
"skype" "" ON \
"eiskaltdcpp-qt" "" ON \
"weechat" "" ON \
"pidgin" "" ON \
"specto" "" ON \
"liferea" "" ON \
"synergy" "" ON \
"dropbox start -i" "" ON 3>&1 1>&2 2>&3)
string=$(echo $string | sed 's/" "/,/g')
string=$(echo $string | sed 's/"//g')
if [ "$(echo $string | grep weechat)" ]; then
string=$(echo $string | sed 's/weechat//g')
nohup guake --execute-command="weechat-curses" &
fi
IFS="," read -ra array <<< "$string"
for i in "${array[@]}"; do
nohup $i >>/dev/null 2>>/dev/null &
done
Soundcloud Downloads
flash-Videos aus dem Browser
...speichern
#!/bin/bash
if [[ `ps x | awk '/libgcflashplayer.so\ /{print $1}'` ]]; then
flashvids() { lsof -p `ps x | awk '/libgcflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
else
flashvids() { lsof -p `ps x | awk '/libflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
fi
echo $(flashvids)
cp $(flashvids) ~/Desktop
Für Youtube: youtube-dl aus den Paketquellen.
...mit mplayer abspielen
#!/bin/bash
if [[ `ps x | awk '/libgcflashplayer.so\ /{print $1}'` ]]; then
flashvids() { lsof -p `ps x | awk '/libgcflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
else
flashvids() { lsof -p `ps x | awk '/libflashplayer.so\ /{print $1}'` -n 2>/dev/null | perl -lne '@F = split(/ +/, $_, 9); print "/proc/$F[1]/fd/${\($F[3] =~ /(^\d+)/)[0]}" if $F[4] eq "REG" && $F[8] =~ /\(deleted\)$/'; }
fi
arr=($(flashvids))
if [[ ${#arr[@]} > 1 ]]; then
echo "${#arr[@]} videos found. Which should be shown?"
read show
mplayer ${arr[($show-1)]}
else
mplayer ${arr[0]}
fi
Unicrawler ohne Moodle
#!/bin/sh -e
function_load(){
cd "${1}" && shift && wget --accept pdf,PDF --execute robots=off --continue --level 1 --no-directories --no-verbose --recursive --timestamping --user-agent "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101" "${@}"
}
function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/TDK" \
--password="*****" \
"http://dante.phys.chemie.tu-muenchen.de/de/vorlesung/pc1/SS2011/materialienSS2011.html" \
function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/IT II/Vorlesung" \
--user="VorlesungIT" --password="*****" \
"http://download.ais.mw.tum.de/IT/index.php?folder=Vm9ybGVzdW5n" \
function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/Bio" \
--user="Chemiker" --password="******" \
"ftp://anakin.biotech.ch.tum.de/Chemie/Biologie%20fuer%20Chemiker/" \
function_load "${HOME}/Dokumente/Studium/Unterlagen/SS_2011/HM II/Vorlesung" \
--user="HM" --password="*****" \
"http://www.ma.tum.de/HM/MW2SoSe11/Inhalt" \
Onlinefestplatten
#!/bin/bash
########################################################################
# #
# Funktionen #
# #
########################################################################
function fqmodus() #Funktion: Modus abfragen
{
echo "Skript zum Anzeigen, Mounten und Unmounten von Onlinefestplatten"
read -p " Anzeigen (a), Mount (m) oder Unmount (u): " modus
}
function fqplatte() #Funktion: Platte abfragen
{
echo "Zur Auswahl stehen geekbox, ownCloud, t-online und MWN"
read -p " Gib die gewünschte Platte ein: " platte
}
function fqnochmal() #Funktion: Abfrage ob nochmal
{
read -p " Fertig? (y/n) " fertig
if [ "$fertig" == "y" ]; then return 1; fi
}
function fanzeigen() #Funktion: eingehängte Platten anzeigen
{
if [ "$(df -h | grep 'geekbox\|ownCloud\|t-online\|MWN')" ]; then
df -h | grep 'geekbox\|ownCloud\|t-online\|MWN'
else
echo "Kein Verzeichnis eingehängt"
fi
}
function fpruef() #Funktion: Prüfen, ob Mountpoint belegt
{
if [ "$(df | grep $1)" ]; then
echo "Warnung: $1 ist bereits eingehängt"
read -p " Trotzdem einhängen? (y/n) " trotzdem
if [ "$trotzdem" == "y" ]; then return 0; fi
return 1
fi
return 0
}
function ftest() #Funktion: Testen, ob wirklich ein/ausgehängt
{
case "$1" in
m)
if [ "$(df | grep $2)" ]; then
echo "$2 erfolgreich eingehängt"
else
echo "$2 wurde nicht eingehängt"
fi
;;
u)
if [ "$(df | grep $2)" ]; then
echo "$2 wurde nicht ausgehängt"
else
echo "$2 erfolgreich ausgehängt"
fi
;;
esac
}
function fmount() #Funktion: Einhängen
{
case "$platte" in
geekbox|g) #geekbox einhängen
if fpruef /media/geekbox; then
nohup sshfs <username>@geekbox.info:/ /media/geekbox > /dev/null 2>&1
ftest $modus /media/geekbox
fi
;;
ownCloud|o) #ownCloud einhängen
if fpruef /media/ownCloud; then
nohup sudo mount -t davfs -o username=<username> <Adresse unter ownCloud->Einstellungen->Persönlich zu finden> /media/ownCloud > /dev/null 2>&1
ftest $modus /media/ownCloud
fi
;;
t-online|t) #t-online einhängen
if fpruef /media/t-online; then
nohup sudo mount -t davfs -o username=<username> https://webdav.mediencenter.t-online.de/ /media/t-online > /dev/null 2>&1
ftest $modus /media/t-online
fi
;;
MWN|mwn|M|m) #MWN einhängen
if fpruef /media/MWN; then
if ! [ "$(ps ax | grep vpnc | grep -v grep)" ]; then #Prüfen, ob eine VPN-Verbindung zum MWN besteht
echo "Es besteht keine VPN-Verbindung zum MWN. Diese wird jetzt aufgebaut."
nohup sudo vpnc <entsprechnde vpnc.conf> > /dev/null 2>&1 #VPN-Verbindung zum MWN herstellen
fi
nohup sudo mount -t cifs -o username=<LRZ-Kennung>,domain=ADS //nas.ads.mwn.de/<LRZ-Kennung> /media/MWN > /dev/null 2>&1
ftest $modus /media/MWN
fi
;;
*) #Fehleingabe abfangen
echo $platte "steht nicht zur Auswahl!"
;;
esac
}
function funmount() #Funktion: Aushängen
{
case "$platte" in
geekbox|g) #geekbox aushängen
fusermount -u /media/geekbox
ftest $modus /media/geekbox
;;
ownCloud|owncloud|o) #ownCloud aushängen
sudo umount /media/ownCloud
ftest $modus /ownCloud
;;
t-online|t) #t-online aushängen
sudo umount /media/t-online
ftest $modus /media/t-online
;;
MWN|mwn|M|m) #MWN aushängen
sudo umount /media/MWN
ftest $modus /media/MWN
;;
*) #Fehleingabe abfangen
echo $platte "steht nicht zur Auswahl!"
;;
esac
}
########################################################################
# #
# Main #
# #
########################################################################
while true; do
clear
fqmodus #Modus abfragen
case "$modus" in
a)
fanzeigen #Anzeigen
;;
m)
fqplatte #Platte abfragen
fmount #Einhängen
;;
u)
fqplatte #Platte abfragen
funmount #Aushängen
;;
*)
echo "Dieser Modus steht nicht zur Auswahl!" #Falscheingaben
;;
esac
if ! fqnochmal; then break; fi #Nochmal von vorne?
done
clear
altes Minecraft-über-Hamachi-Skript
#!/bin/bash
########################################################################
# #
# Konfiguration #
# #
########################################################################
#IP des Servers
IP="<IP>"
#DynDns des Servers
DNS="<DynDns>"
#Hamachi Netzwerkname
HAHACHI="<Netzwerkname>"
#Zeit zwischen den Pings
PAUSE=3
#wie viele Fehler vor reconnect
TOLERANZ=2
########################################################################
# #
# DynDNS testen #
# #
########################################################################
if ping -c 1 -w 1 $DNS > /dev/null; then
DYNDNS=true
else
DYNDNS=false
fi
########################################################################
# #
# Spiel starten #
# #
########################################################################
if $DYNDNS; then
echo "************ DynDNS verwenden:" $DNS "************"
else
echo "************ Hamachi verwenden:" $IP "************"
if ! ping -c 1 -w 1 $IP > /dev/null; then
gksudo tuncfg
hamachi go-offline $HAHACHI
hamachi logout
hamachi stop
hamachi start
hamachi login
hamachi go-online $HAHACHI
hamachi get-nicks
#hamachi list
fi
fi
java -jar <Pfad>/minecraft.jar &
########################################################################
# #
# Verbindungsüberwachung #
# #
########################################################################
sleep 10
FEHLER=0
if $DYNDNS; then
while true; do
if ! ping -c 1 -w 1 $DNS > /dev/null; then
FEHLER=$((FEHLER+1))
else
FEHLER=0
fi
if [ $FEHLER -eq $TOLERANZ ]; then
echo "************ DynDNS-Verbindung unterbrochen ************"
FEHLER=0
fi
sleep $PAUSE
done
else
while true; do
if ! ping -c 1 -w 1 $IP > /dev/null; then
FEHLER=$((FEHLER+1))
else
FEHLER=0
fi
if [ $FEHLER -eq $TOLERANZ ]; then
echo "************ Hamachi-Verbindung unterbrochen -> reconnecting ************"
gksudo tuncfg
hamachi go-offline $HAHACHI
hamachi logout
hamachi stop
hamachi start
hamachi login
hamachi go-online $HAHACHI
hamachi get-nicks
#hamachi list
fi
sleep $PAUSE
done
fi