?

Log in

No account? Create an account
Unix-Solution [entries|archive|friends|userinfo]
Unix-Solution

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

DHCP Hook for static-routes [Sep. 16th, 2008|02:24 pm]
Unix-Solution

maximum_value
[Tags|, , ]

Script for applying static-routes from DHCP server.

Script must be placed in '/etc/dhcp3/dhclient-exit-hooks.d/'
(for example: /etc/dhcp3/dhclient-exit-hooks.d/configure_static_routes)

Was tested in Ubuntu 8.04.1

#!/bin/sh

function process_routes() {
  while [ $# -gt 1 ]
  do
    dest=$1
    gateway=$2
    shift; shift
    route add $dest gw $gateway
  done
}

if [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]
then
  echo "static_routes = $new_static_routes"
  process_routes $new_static_routes
fi

linkpost comment

Patch Dokuwiki for new user registration with OpenLDAP [Dec. 8th, 2007|05:04 pm]
Unix-Solution

maximum_value
Applies for Dokuwiki from 2006-03-05 up to 2007-06-26 (may be later)


PatchCollapse )
linkpost comment

Apache: Redirect to https on logon (register) and redirect to http on logout. [Dec. 3rd, 2007|07:21 pm]
Unix-Solution

maximum_value
Problem
Need make secure always logon and register operations on your web-site
Query pamams: do=login, do=register, do=logout
Logon form: separate page

Solution

Put this text to apache (or host) configuration or to .htaccess file

RewriteCond %{QUERY_STRING} do=login [OR]
RewriteCond %{QUERY_STRING} do=register
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

RewriteCond %{QUERY_STRING} do=logout
RewriteCond %{HTTPS} =on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L]
link4 comments|post comment

Backup live (mounted) file system on FreeBSD [Aug. 20th, 2007|06:43 pm]
Unix-Solution

maximum_value
Problem: realtime backup live file system on FreeBSD. Slices: root directory, /var and /usr.

Solution:

Simple backup
#!/bin/sh
day=`date "+%w"`
backup_dir="/mnt/backup"
dump="dump -C 8 -Lf -"
if [ "$day" -ne 3 ] && [ "$day" -ne 6 ]; then exit 0; fi # start only for two days of week (start daily by cron)
cd $backup_dir || exit 1
$dump / > root.$day.bkp
$dump /var > var.$day.bkp
$dump /usr > usr.$day.bkp
Restore from backup
cd /mnt/new_mount_point
restore -rf /mnt/backup/xxx.bkp
Backup and gzip
#!/bin/sh
day=`date "+%w"`
backup_dir="/mnt/backup"
dump="dump -C 8 -Lf -"
if [ "$day" -ne 3 ] && [ "$day" -ne 6 ]; then exit 0; fi
cd $backup_dir || exit 1
$dump / | gzip > root.$day.bkp.gz
$dump /var | gzip > var.$day.bkp.gz
$dump /usr | gzip > usr.$day.bkp.gz
Restore from gzip backup
cd /mnt/new_mount_point
gunzip /mnt/backup/xxx.bkp.gz | restore -rf -

PS: If you want to do live backup on Linux you can use LVM+snapshot system.
linkpost comment

HP LaserJet 10xx on Ubuntu Linux (1000 1005 1018 1020) [Aug. 15th, 2007|11:15 am]
Unix-Solution

maximum_value
HP Laserjet 10xx (1000 1005 1018 1020 - often erroneously referred to as "winprinters") use foo2zjs on Linux, but dont work on many distros by default. Ubuntu one of them.

foo2zjs site (http://foo2zjs.rkkda.com/) recommend use official source from http://foo2zjs.rkkda.com/foo2zjs.tar.gz, but it can make hard to update system.

I recommend use this script for make this printer to work.
(Use this script for install needed firmwares for HP LaserJet 10xx. You must be connected to the Internet)


#!/bin/bash
printers="1000 1005 1018 1020"
cd /tmp
for prn in $printers; do
    img="sihp${prn}.img"
    dl="sihp${prn}.dl"
    getweb $prn
    if [ -f $img ]; then
        arm2hpdl $img > $dl
        sudo cp $dl /usr/share/foo2zjs/firmware/$dl
        rm $img $dl
    fi;
done


Turn off/on your printer.
Tested on Ubuntu Feisty 7.04.
link10 comments|post comment

cdrecord and ISO Image [Dec. 26th, 2006|10:14 am]
Unix-Solution

maximum_value
For write ISO image to CD you must use SAO (session at once) or DAO (disk at once) mode. If you use TAO mode (default) for write image.iso - CD Disk may not readable at the last tracks of Disk.
For example:
cdrecord -v -sao image.iso
or
cdrecord -v -dao image.iso
linkpost comment

Close window application by mouse middle button click on titlebar in WMII [Dec. 15th, 2006|09:50 am]
Unix-Solution

maximum_value
add to wmiirc:
# EVENT LOOP
...
ClientClick)
                [ $2 = 2 ] && /client/$1/ctl kill;;
...
linkpost comment

Autoselect Tag to View on open new Window (Автоматический переход на Таг с появившимся окном) [Dec. 13th, 2006|12:54 pm]
Unix-Solution

maximum_value
add to wmiirc:
# EVENT LOOP
...
CreateClient)
	xwrite /ctl view `wmiir read /client/$1/tags | cut -d+ -f1`;
...
linkpost comment

Select Named Tags by ModKey + Number (WMII-3) [Nov. 30th, 2006|04:11 pm]
Unix-Solution

maximum_value
wmiirc (change):

$MODKEY-[0-9])
    xwrite /ctl view `echo $1 | sed 's/.*-//'`;;
to
$MODKEY-[0-9])
    xwrite /ctl view "`wmiir read /tags | sed -n \`echo $1 | sed 's/.*-//'\`p`";;
linkpost comment

Move to previous and next Tag key bindings in wmii-3 (Назначение клавиш перемещения между Тэгами) [Nov. 28th, 2006|05:06 pm]
Unix-Solution

maximum_value
add to wmiirc:

# SHORTCUTS
...
$MODKEY-comma
$MODKEY-period
...
# EVENT LOOP
...
$MODKEY-comma)
    xwrite /ctl view "`wmiir read /tags | grep \`wmiir read /view/name\` -B 1 | line`";;
$MODKEY-period)
    xwrite /ctl view "`wmiir read /tags | grep \`wmiir read /view/name\` -A 1 | tail -n 1`";;
...
linkpost comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]