|
This will be my dumpbox of all kind of scripts I created. Use it to your advantage!!!
To have the scripts on every computer I want I use Subversion. Subversion is actually a version management tool, but together with ssh it makes the live of any system administrator a lot easier. Take a look at my scripts below.
To be kept up-to-date you can register and subscribe to the computer section or to one of the categories.
|
|
Written by Bart Dorlandt
|
|
Monday, 14 April 2008 00:28 |
|
Here is a one-liner to rename everyfile in the current directory without using the command rename. (this command isn't available on OpenBSD, so I had to use this solution)
for i in ./* ; do mv "$i" `echo "$i" | sed 's/ /_/g'`; done
|
|
Last Updated on Sunday, 13 July 2008 17:06 |
|
Written by Bart Dorlandt
|
|
Friday, 29 June 2007 11:51 |
Empty cd
#!/bin/sh
cdrdao blank --device /dev/hda --driver generic-mmc
eject
Empty dvd
#!/bin/sh
mkdir ~/leeg
growisofs -quiet -Z /dev/dvd -R -J ~/leeg
rmdir ~/leeg
dvd backup
#!/bin/sh
WEEKNR=`date +%V`
growisofs -Z /dev/dvd -R -J -l -V BackUP${WEEKNR} /data/Backup/Server
Here are some extra hints
|
|
Last Updated on Sunday, 13 July 2008 17:16 |
|
Written by Bart Dorlandt
|
|
Friday, 29 June 2007 11:34 |
|
I use this script with the IF statements because I use subversion to
keep control of my scripts and use different machines which do the same
tasks.
NFS
#!/bin/bash
method1() {
mount -t nfs -o rsize=8192,wsize=8192,retry=1 <server_IP or DNS>:/data /mnt/nfs
}
method2() {
mount_nfs -R1 <server_IP or DNS>:/data /mnt/kamer
}
MACHINE=`uname`
if [ "$MACHINE" = "Linux" ]; then
method1
else
if [ "$MACHINE" = "FreeBSD" ]; then
method2
fi
fi
Samba
method1() {
mount -t cifs //<servername>/data /mnt/samba -o user=<remote_username>,uid=<local_username>
}
method2() {
mount_smbfs -W <work_group> -u <local_username> //<remote_username>@<servername>/data /mnt/samba/
}
MACHINE=`uname`
if [ "$MACHINE" = "Linux" ]; then
method1
else
if [ "$MACHINE" = "FreeBSD" ]; then
method2
fi
fi
|
|
Last Updated on Tuesday, 17 July 2007 14:34 |
|
Written by Bart Dorlandt
|
|
Friday, 29 June 2007 00:25 |
Rotate image files
#! /bin/sh
DEGREES=$1
if [ "$DEGREES" = "" ] ; then
echo "Use the script as described below"
echo "~/script/image/rotate.sh [value]."
else
mkdir draaien
for img in `ls *.JPG *.jpg`
do
convert -rotate $DEGREES $img draaien/$img
echo "image $img is turned $DEGREES degrees."
done
fi
Resize
#! /bin/sh
SIZE=$1
if [ "$SIZE" = "" ] ; then
echo "Use the script as described below"
echo "~/script/image/resize.sh [value]."
else
mkdir resize
for img in `ls *.jpg *.JPG`
do
convert -resize $SIZE $img resize/$img
echo "$img is adjusted to width:$SIZE, length is adjusted too"
done
fi
|
|
Last Updated on Tuesday, 17 July 2007 14:34 |
|
Written by Bart Dorlandt
|
|
Friday, 29 June 2007 00:20 |
|
Echo all directories in the subdir: /var/www/upload/foto/albums
for x in `find /var/www/upload/foto/albums -type d ` ; do echo $x ; done
Go into every directory and execute the script resize. This script can be found here.
for x in `find /var/www/upload/foto/albums -type d` ; do cd $x ; \
/home/bart/scripts/image/resize.sh 800 ; done
Go into every directory that hasn't the name resize and move all the contents of the directory resize into the directory below.
for x in `find /var/www/upload/foto/albums -type d | grep -v resize` ; do cd $x ; mv resize/* . ; done
Remove all empty directories.
find . -depth -type d | xargs rmdir 2>/dev/null
for more examples on how to use find, please take a look here.
|
|
Last Updated on Tuesday, 01 April 2008 11:13 |
|
Written by Bart Dorlandt
|
|
Friday, 29 December 2006 11:45 |
|
I used this script for FreeBSD and for Linux Ubuntu 6.06. Since I use 7.04 with the Network manager Applet I haven't been using this script anymore. Also because I don't have FreeBSD no more.
Here is a sample config
#!/bin/bash
# wireless-enable.sh
LinuxWPA() {
ifconfig eth1 up
ifconfig eth0 down
echo "execute wpa_supplicant, sleep 10"
/sbin/wpa_supplicant -i eth1 -c /etc/conf/wireless/wpa_supplicant.conf -D ipw & >/dev/null 2>&1
sleep 10
echo "retrieve IP adress"
/sbin/dhclient eth1 >/dev/null 2>&1
ifconfig eth1
}
FreebsdWPA() {
ifconfig bge0 down
echo "load drivers"
# /sbin/kldload -v if_iwi wlan_wep wlan_ccmp wlan_tkip
/sbin/kldload -v if_iwi wlan_acl wlan_wep wlan_ccmp wlan_tkip
echo "load firmware"
/usr/sbin/iwicontrol -i iwi0 -d /boot/firmware -m bss
echo "execute wpa_supplicant, sleep 10"
/sbin/wpa_supplicant -i eth1 -c /etc/conf/wireless/wpa_supplicant.conf & >/dev/null 2>&1
sleep 10
echo "retrieve IP adress"
/sbin/dhclient iwi0 >/dev/null 2>&1
ifconfig iwi0
}
MACHINE=`uname`
if [ "$MACHINE" = "Linux" ]; then
LinuxWPA
else
if [ "$MACHINE" = "FreeBSD" ]; then
FreebsdWPA
fi
fi
|
|
Last Updated on Tuesday, 20 November 2007 17:51 |
|
|
|
|
|