Einige Skripte zur freien Verfügung.
Seiteninhalt
Bashskripte verfügbar machen:
/home/«Benutzername»/bin, ausführbar machen chmod 750 «Skriptname» /usr/local/bin, ausführbar machen chmod 755 «Skriptname» (systemweit verfügbar)
#!/bin/bash # schnell den befehl von gestern in der history finden var="$1" if [ "$var" = "" ]; then echo "gih - (g)et (i)n (h)istory - sucht in der Befehlshistory nach ihrer Eingabe" echo "Syntax: gih <Suchbegriff>" exit 0 fi grep $var ~/.bash_history exit 0
#!/bin/bash # SYNCAH # Version 0.8 # Autor: Hardy L., h@rdyl.de # Was es tut, descr. in brief: # sync-t Verzeichnisse. Loggt nach /tmp # # Description: # This script is synchronise two directorys. By default it ! DELETE ! # files and folders in the target to have the same content in both # directorys. Either it try to keep ownership, rights and times from # the source. # Normaly the target dirctory should have the date and time of the # last sync action, so you can easy check when it was. # # No warranty. Use at your own risk. # # You can contact author at http://forum.fossclub.de/ # -------------------------------------------------------------------- # 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 2 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, write to: # Free Software Foundation, Inc., # 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA # -------------------------------------------------------------------- # Systemvorrausetzungen: # bash, _rsync_, echo, date, touch # ein /tmp-Verzeichnis mit Schreibrecht für $USER # # Todo: # - prüfen Variable 2/target existiert # - prüfen ob ein abschließender Slash vorhanden ist # Variablen zuweisen, die wir später einsetzen source="$1" target="$2" position=`pwd` # Wenn keine Parameter angegeben werden, wird eine Hilfe angezeigt und beendet if [ "$source" = "" ]; then echo "*** SYNCAH ***" echo "- Synchronisiert Verzeichnisse (rsync -ah --delete --progress)" echo "- Schreibt ein Log nach /tmp" echo "Syntax: syncah <Verz.Quelle/> <Verz.Ziel/>" echo "Beachte den abschließenden Slash am Ende!!" echo "Tipp: Ziel oder Quelle können auch auf einem SSH-Server sein" echo "Schreibweise: <NameEntf.User>@<ServerName/ServerIP>:/pfad/zu/quelle/oder/ziel/" exit 0 fi # Das Quellverzeichnis 'touch'en, sprich mit der aktuellen Systemzeit versehen (nur lokale Verz.) touch $source # Zeit, Quellverz., Arbeitsverz., Zielverz. wir nach /tmp/syncdirs<Datum><User>.txt geschrieben/angehängt echo -e "ZEIT:_ $(date +'%R') \nSYNC VON:_ $source \nSTANDORT:_ $position \nSYNC NACH:_ $target \n-----" \ >>/tmp/syncdirs$(date +'%d%b%y')-$USER.txt # Jetzt geht's an die Arbeit. Der rsync-Befehle und die Parameter. Parameter nachzulesen in 'man rsync' # Logdatei wird nach /tmp/syncah<Datum>-<User>-<Zeit>-log.txt geschrieben. Lebenszeit bis zum nächsten Neustart rsync -ah --delete --progress --log-file=/tmp/syncah$(date +'%d%b%y')-$USER-$(date +'%R')-log.txt $source $target # rsync ist fertig. Hänge noch ein Notiz an die Ausgabe echo "------ DONE --------------------------------------------------" echo "-- Synchronisation beendet -> Die Logdateien liegen in /tmp --" echo "----------------------------------------- h@rdyl.de ----------" # Verlassen exit 0