public:scripts
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
public:scripts [2014/08/22 13:21] – [gdrive_sync.sh] Roland Hansmann | public:scripts [2018/02/06 11:10] (current) – [accounts.sh] Roland Hansmann | ||
---|---|---|---|
Line 46: | Line 46: | ||
<? | <? | ||
$file = fread($handler, | $file = fread($handler, | ||
- | preg_match_all('/ | + | preg_match_all('/ |
$urls = $urls[2]; | $urls = $urls[2]; | ||
$rowclass = 0; | $rowclass = 0; | ||
Line 192: | Line 192: | ||
===== BaSH ===== | ===== BaSH ===== | ||
+ | ==== update_dokuwiki.sh ==== | ||
+ | This script updates dokuwiki from tgz file on your document root. The updating file must be named dokuwiki*.tgz | ||
+ | <file bash update_dokuwiki.sh> | ||
+ | #!/bin/bash | ||
+ | set -e | ||
+ | |||
+ | # Set your install dir | ||
+ | INSTALLDIR=/ | ||
+ | |||
+ | [[ `whoami` != " | ||
+ | [[ `pwd` != " | ||
+ | |||
+ | DOKUFILE=`ls $INSTALLDIR/ | ||
+ | [[ -z $DOKUFILE ]] && { echo "No TAR file found matching dokuwiki*.tgz"; | ||
+ | |||
+ | cd $INSTALLDIR | ||
+ | |||
+ | echo " | ||
+ | rm -rf dokuwiki.old | ||
+ | |||
+ | echo " | ||
+ | mv dokuwiki dokuwiki.old | ||
+ | |||
+ | echo " | ||
+ | tar -xzf $DOKUFILE | ||
+ | |||
+ | echo " | ||
+ | mv `find . -type d -name " | ||
+ | |||
+ | echo " | ||
+ | find dokuwiki -name *.dist -exec rm -rf {} \; | ||
+ | |||
+ | echo "Get local configs and acl.auth.php from previous installation" | ||
+ | find dokuwiki.old/ | ||
+ | cp -p dokuwiki.old/ | ||
+ | |||
+ | echo "Get custom smileys from previous installation" | ||
+ | for i in `awk ' | ||
+ | printf " $i" | ||
+ | cp dokuwiki.old/ | ||
+ | done | ||
+ | echo "" | ||
+ | |||
+ | echo "Rsync data from previous installation" | ||
+ | rsync -a --delete dokuwiki.old/ | ||
+ | |||
+ | echo "Clear update messages" | ||
+ | echo "" | ||
+ | |||
+ | echo "Copy active template from previous installation" | ||
+ | TPL=`grep template dokuwiki.old/ | ||
+ | cp -pr dokuwiki.old/ | ||
+ | |||
+ | echo "Copy custom installed plugins" | ||
+ | for i in `ls dokuwiki.old/ | ||
+ | if [[ ! `ls dokuwiki/ | ||
+ | printf " $i" | ||
+ | cp -pr dokuwiki.old/ | ||
+ | fi | ||
+ | done | ||
+ | echo "" | ||
+ | |||
+ | echo " | ||
+ | chown -R www-data dokuwiki/ | ||
+ | chown www-data dokuwiki/ | ||
+ | |||
+ | / | ||
+ | </ | ||
==== ipcheck.sh ==== | ==== ipcheck.sh ==== | ||
This script is executed every 30 minutes by cron from root. It checks if the public IP has changed and sends an email with the notification to dislist the new IP from Spamhaus Blacklist. | This script is executed every 30 minutes by cron from root. It checks if the public IP has changed and sends an email with the notification to dislist the new IP from Spamhaus Blacklist. | ||
Line 839: | Line 907: | ||
# added rescanning if SSID input is blank | # added rescanning if SSID input is blank | ||
# Thu Sep 18 10:30:15 CEST 2008 / added function to scan available interface | # Thu Sep 18 10:30:15 CEST 2008 / added function to scan available interface | ||
- | # | + | # |
# Wed Aug 19 11:37:54 CEST 2009 / more optimized | # Wed Aug 19 11:37:54 CEST 2009 / more optimized | ||
+ | # Mon Oct 3 14:53:59 CEST 2016 / dialog' | ||
# | # | ||
# | # | ||
IFACE=$1 | IFACE=$1 | ||
+ | umask 0002 # secure tmp files | ||
+ | pkill wpa_supplicant # kill existing wpa processes | ||
+ | |||
+ | DIALOGBIN=`which dialog` | ||
+ | if [[ -z $DIALOGBIN ]] ; then | ||
+ | DIALOG= | ||
+ | else | ||
+ | # | ||
+ | DIALOG=1 | ||
+ | TMP=/ | ||
+ | trap "rm -rf $TMP" INT TERM EXIT | ||
+ | fi | ||
# Check if Parameter is a valid Interface to use. If not, the Script proposes | # Check if Parameter is a valid Interface to use. If not, the Script proposes | ||
Line 849: | Line 930: | ||
ifconfig $IFACE > /dev/null | ifconfig $IFACE > /dev/null | ||
if [ " | if [ " | ||
- | FINDIFACE=`iwconfig |grep IEEE |awk ' | + | |
- | clear | + | if [[ $DIALOG ]]; then |
- | echo " | + | $DIALOGBIN --title " |
- | echo " | + | else |
- | read | + | |
- | IFACE=$FINDIFACE | + | echo " |
+ | echo " | ||
+ | read | ||
+ | fi | ||
+ | | ||
fi | fi | ||
# Output a Usage if no Parameter is given | # Output a Usage if no Parameter is given | ||
if [ " | if [ " | ||
- | echo " | + | |
- | exit 1 | + | exit 1 |
fi | fi | ||
clear | clear | ||
+ | ifconfig $IFACE up | ||
- | echo " | + | if [[ $DIALOG ]]; then |
- | echo "" | + | $DIALOGBIN --infobox " |
- | iwlist $IFACE scanning |grep ESSID | + | SSIDLIST=`iwlist $IFACE scanning |grep ESSID |cut -f2 -d\" |grep -v " |
- | echo "" | + | SSIDLISTSIZE=`echo $SSIDLIST |wc -w` |
- | echo "Enter ESSID you want to connect or leave blank to rescan and press [ENTER]:" | + | $DIALOGBIN |
- | read SSID | + | SSID=`cat $TMP` |
+ | else | ||
+ | | ||
+ | echo "" | ||
+ | iwlist $IFACE scanning |grep ESSID | ||
+ | echo "" | ||
+ | echo "Enter ESSID you want to connect or leave blank to rescan and press [ENTER]:" | ||
+ | read SSID | ||
+ | fi | ||
# If the Input is empty, the Script loops over the scan and asks each time to enter | # If the Input is empty, the Script loops over the scan and asks each time to enter | ||
# a SSID to continue with the connection | # a SSID to continue with the connection | ||
- | while [ "$SSID" == "" | + | while [[ -z $SSID ]]; do |
- | clear | + | clear |
- | echo " | + | if [[ $DIALOG ]]; then |
- | iwlist $IFACE scanning |grep ESSID | + | $DIALOGBIN --infobox |
- | echo "Enter ESSID you want to connect or leave blank to rescan and press [ENTER]:" | + | SSIDLIST=`iwlist $IFACE scanning |grep ESSID |cut -f2 -d\" |grep -v " |
- | echo "" | + | SSIDLISTSIZE=`echo $SSIDLIST |wc -w` |
- | read SSID | + | $DIALOGBIN --title |
+ | | ||
+ | else | ||
+ | echo " | ||
+ | iwlist $IFACE scanning |grep ESSID | ||
+ | echo "Enter ESSID you want to connect or leave blank to rescan and press [ENTER]:" | ||
+ | echo "" | ||
+ | read SSID | ||
+ | fi | ||
done | done | ||
Line 886: | Line 988: | ||
sleep 1 | sleep 1 | ||
- | # Show details | + | # Encryption select |
- | clear | + | if [[ $DIALOG ]]; then |
- | echo "You are connecting to $SSID" | + | $DIALOGBIN --title " |
- | echo "Details:" | + | ENCRYPT=`cat $TMP` |
- | iwlist $IFACE scanning essid $SSID |egrep | + | else |
+ | clear | ||
+ | echo "You are connecting to $SSID" | ||
+ | |||
+ | | ||
+ | | ||
+ | echo "2: WPA" | ||
+ | read ENCRYPT | ||
+ | fi | ||
- | echo " | ||
- | echo "1: None" | ||
- | echo "2: WPA" | ||
- | read ENCRYPT | ||
case " | case " | ||
- | 1) | + | |
- | ;; | + | ;; |
- | 2) | + | 2) |
- | # Check if wpa_supplicant is installed and quit if not | + | # Check if wpa_supplicant is installed and quit if not |
- | which wpa_supplicant | + | if [[ ! `which wpa_supplicant` ]]; then |
- | if [ $? == " | + | if [[ $DIALOG ]]; then |
- | echo " | + | |
- | exit 1 | + | else |
- | fi | + | |
- | echo "Enter Passpharse: " | + | fi |
- | read -s PASS | + | |
+ | fi | ||
+ | if [[ $DIALOG ]]; then | ||
+ | $DIALOGBIN --passwordbox "Enter Passphrase" | ||
+ | PASS=`cat $TMP` | ||
+ | else | ||
+ | | ||
+ | read -s PASS | ||
+ | fi | ||
- | # Store the entered Passphrase as WPA Key and start wpa_supplicant | + | |
- | # process in the background | + | # process in the background |
- | wpa_passphrase $SSID $PASS > / | + | wpa_passphrase $SSID $PASS > / |
- | wpa_supplicant -Dwext -i$IFACE -c/ | + | chmod 600 /etc/wpa_supplicant/ |
- | ;; | + | wpa_supplicant -B -Dwext -i$IFACE -c/ |
- | *) | + | ;; |
- | echo "Wrong selection, aborting!" | + | *) |
- | exit 1 | + | if [[ $DIALOG ]]; then |
- | ;; | + | $DIALOGBIN --infobox "Wrong selection. Aborted!" |
+ | else | ||
+ | | ||
+ | fi | ||
+ | | ||
+ | ;; | ||
esac | esac | ||
# Renew the IP and quit smoothly | # Renew the IP and quit smoothly | ||
- | dhclient $IFACE | + | if [[ $DIALOG ]]; then |
- | exit 0 | + | $DIALOGBIN --infobox " |
+ | | ||
+ | else | ||
+ | dhclient -v -1 $IFACE | ||
+ | fi | ||
</ | </ | ||
Line 1156: | Line 1280: | ||
# decrypt file and exit immediately if passphrase is wrong | # decrypt file and exit immediately if passphrase is wrong | ||
- | gpg -d $ACCOUNTFILE.gpg > $ACCOUNTFILE || exit 2 | + | $GPGBIN |
- | + | ||
- | # remove old encrypted file | + | |
- | rm -f $ACCOUNTFILE.gpg | + | |
# edit | # edit | ||
- | vi $ACCOUNTFILE | + | $VIBIN |
- | # encrypt new file | + | # encrypt new file and overwrite existing one |
echo " | echo " | ||
- | gpg -e -r $USER $ACCOUNTFILE | + | $GPGBIN --yes -e -r $USER $ACCOUNTFILE |
# remove unencrypted file | # remove unencrypted file | ||
Line 1461: | Line 1582: | ||
ifconfig $MON down | ifconfig $MON down | ||
</ | </ | ||
+ | ==== spacewalk-package-installed ==== | ||
+ | This script shows which servers have installed a specific package | ||
+ | <file bash spacewalk-package-installed> | ||
+ | #!/bin/bash | ||
+ | PACKAGE=$1 | ||
+ | VERSION=$2 | ||
+ | RELEASE=$3 | ||
+ | [[ $@ -ne 3 ]] && { echo " | ||
+ | |||
+ | for id in `/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | |cut -f1 -d, |grep -v ^system_id` | ||
+ | do | ||
+ | / | ||
+ | | ||
+ | |cut -f3 -d, |tail -1 | ||
+ | done | ||
+ | </ | ||
===== C ===== | ===== C ===== | ||
public/scripts.1408713662.txt.gz · Last modified: 2014/08/22 13:21 by Roland Hansmann