User Tools

Site Tools


public:scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:scripts [2016/10/03 14:29] – [ssid] Roland Hansmannpublic:scripts [2018/02/06 11:10] (current) – [accounts.sh] Roland Hansmann
Line 46: Line 46:
                 <?$handler = fopen($target_path,"r");                 <?$handler = fopen($target_path,"r");
                 $file = fread($handler,filesize($target_path));                 $file = fread($handler,filesize($target_path));
-                preg_match_all('/(<A HREF=\")(.*)(\" ADD_DATE)/Ui',$file,&$urls);+                preg_match_all('/(<A HREF=\")(.*)(\" ADD_DATE)/Ui',$file,$urls);
                 $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=/var/www
 +
 +[[ `whoami` != "root" ]] && { echo "Must be root"; exit 2; }
 +[[ `pwd` != "$INSTALLDIR" ]] && { echo "You must be in $INSTALLDIR instead in `pwd`"; exit 2; }
 +
 +DOKUFILE=`ls $INSTALLDIR/dokuwiki*.tgz  |awk -F/ '{print $NF}'`
 +[[ -z $DOKUFILE ]] && { echo "No TAR file found matching dokuwiki*.tgz"; exit 2; }
 +
 +cd $INSTALLDIR
 +
 +echo "Removing old backup dokuwiki.old"
 +rm -rf dokuwiki.old
 +
 +echo "Backup current Dokuwiki to dokuwiki.old"
 +mv dokuwiki dokuwiki.old
 +
 +echo "Extracting new TAR"
 +tar -xzf $DOKUFILE
 +
 +echo "Rename extracted directory to dokuwiki if not yet"
 +mv `find . -type d -name "dokuwiki-*"` dokuwiki
 +
 +echo "Remove .dist files in the new installation"
 +find dokuwiki -name *.dist -exec rm -rf {} \;
 +
 +echo "Get local configs and acl.auth.php from previous installation"
 +find dokuwiki.old/conf -name "*local*" -exec cp -p {} dokuwiki/conf \;
 +cp -p dokuwiki.old/conf/acl.auth.php dokuwiki/conf
 +
 +echo "Get custom smileys from previous installation"
 +for i in `awk '{print $NF}' dokuwiki.old/conf/smileys.local.conf`; do
 +        printf " $i"
 +        cp dokuwiki.old/lib/images/smileys/$i dokuwiki/lib/images/smileys
 +done
 +echo ""
 +
 +echo "Rsync data from previous installation"
 +rsync -a --delete dokuwiki.old/data dokuwiki
 +
 +echo "Clear update messages"
 +echo "" > dokuwiki/data/cache/messages.txt
 +
 +echo "Copy active template from previous installation"
 +TPL=`grep template dokuwiki.old/conf/local.php |cut -f4 -d\'`
 +cp -pr dokuwiki.old/lib/tpl/$TPL dokuwiki/lib/tpl
 +
 +echo "Copy custom installed plugins"
 +for i in `ls dokuwiki.old/lib/plugins/`; do
 +        if [[ ! `ls dokuwiki/lib/plugins/$i 2>/dev/null` ]]; then
 +                printf " $i"
 +                cp -pr dokuwiki.old/lib/plugins/$i dokuwiki/lib/plugins
 +        fi
 +done
 +echo ""
 +
 +echo "Fixing permissions"
 +chown -R www-data dokuwiki/data dokuwiki/lib/plugins
 +chown www-data dokuwiki/conf dokuwiki/conf/local.php dokuwiki/conf/acl.auth.php
 +
 +/etc/init.d/apache2 reload
 +</file>
 ==== 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 855: Line 923:
         DIALOG=1         DIALOG=1
         TMP=/tmp/tmp.$$         TMP=/tmp/tmp.$$
-        trap "rm -rf $TMP; exitSIGHUP SIGINT SIGTERM+        trap "rm -rf $TMP" INT TERM EXIT
 fi fi
  
Line 927: Line 995:
         clear         clear
         echo "You are connecting to $SSID"         echo "You are connecting to $SSID"
-        iwlist $IFACE scanning essid $SSID |egrep "ESSID|Quality|Encryption" 
  
         echo "Please select Security: "         echo "Please select Security: "
Line 964: Line 1031:
         *)         *)
                 if [[ $DIALOG ]]; then                 if [[ $DIALOG ]]; then
-                        $DIALOGBIN --infobox "Wroing selection. Aborted!" 3 60+                        $DIALOGBIN --infobox "Wrong selection. Aborted!" 3 60
                 else                 else
                         echo "Wrong selection. Aborted!"                         echo "Wrong selection. Aborted!"
Line 974: Line 1041:
 # Renew the IP and quit smoothly # Renew the IP and quit smoothly
 if [[ $DIALOG ]]; then if [[ $DIALOG ]]; then
-        $DIALOGBIN --infobox "Obtaining IP Address\n\n If this process takes longer than 15s,\n you may enter a wrong key" 6 60+        $DIALOGBIN --infobox "Obtaining IP Address\n\n If this process takes longer than 15s,\n you may enter a wrong key or no DHCP server present" 6 60
         dhclient -q -1 $IFACE         dhclient -q -1 $IFACE
 else else
Line 1213: 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 -d $ACCOUNTFILE.gpg > $ACCOUNTFILE || exit 2
- +
-# remove old encrypted file +
-rm -f $ACCOUNTFILE.gpg+
  
 # edit # edit
-vi $ACCOUNTFILE+$VIBIN $ACCOUNTFILE
  
-# encrypt new file+# encrypt new file and overwrite existing one
 echo "Encrypting ..." echo "Encrypting ..."
-gpg -e -r $USER $ACCOUNTFILE+$GPGBIN --yes -e -r $USER $ACCOUNTFILE
  
 # remove unencrypted file # remove unencrypted file
Line 1518: Line 1582:
 ifconfig $MON down ifconfig $MON down
 </file> </file>
 +==== 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 "Usage: $0 packagename version release"; exit 2; }
 +
 +for id in `/usr/bin/spacewalk-report system-packages-installed \
 +           --where-package_name=$PACKAGE \
 +           --where-package_version=$VERSION \
 +           --where-package_release=$RELEASE \
 +           |cut -f1 -d, |grep -v ^system_id`
 +        do
 +           /usr/bin/spacewalk-report inventory \
 +           --where-server_id=$id \
 +           |cut -f3 -d, |tail -1
 +done
 +</file>
 ===== C ===== ===== C =====
  
public/scripts.1475504943.txt.gz · Last modified: 2016/10/03 14:29 by Roland Hansmann