bash network calculation 
IP='130.10.10.10'
NETMASK='255.255.252.0'

l="${IP%.*}";r="${IP#*.}";n="${NETMASK%.*}";m="${NETMASK#*.}"

SUBNET=$((${IP%%.*}&${NETMASK%%.*})).\
$((${r%%.*}&${m%%.*})).\
$((${l##*.}&${n##*.})).\
$((${IP##*.}&${NETMASK##*.}))

l="${SUBNET%.*}";r="${SUBNET#*.}"

BROADCAST=$((${SUBNET%%.*}|256+~${NETMASK%%.*})).\
$((${r%%.*}|256+~${m%%.*})).\
$((${l##*.}|256+~${n##*.})).\
$((${SUBNET##*.}|256+~${NETMASK##*.}))
SUBNET is 130.10.8.0
BROADCAST is 130.10.11.255

[ view entry ] ( 586 views )   |  print article
xorg Xinerama / Dual Screen 
The hard work with xinerama / dual screen was:

* set the monitor sync/refresh rate (it won't start without for an old crt not supporting ddc)

* set Option "NoAccel" "true" (screen distortions)

* touchpad only works with dual screen

* instabilities with two different cards (via / ati - resolved by using only ati card that has two VGA connectors)

Testing with: #> X -config /absolutepath/xorg.conf -verbose

xinerama xorg.conf:
Section "Files"
FontPath "/usr/share/X11/fonts/misc"
FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
FontPath "/usr/share/X11/fonts/75dpi"
EndSection

Section "Module"
Load "i2c"
Load "bitmap"
Load "ddc"
Load "dri"
Load "extmod"
SubSection "extmod"
Option "omit xfree86-dga"
EndSubSection
Load "int10"
Load "vbe"
Load "dbe"
EndSection

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "ru,us"
Option "XkbOptions" "grp:caps_toggle"
EndSection

Section "InputDevice"
Identifier "Generic Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
EndSection

Section "Device"
Identifier "dev0"
Driver "via"
BusID "PCI:1:0:0"
Screen 0
EndSection

Section "Device"
Identifier "dev1"
Driver "mga"
BusID "PCI:0:20:0"
Screen 1
EndSection

Section "Monitor"
Identifier "monitor0"
Option "DPMS"
EndSection

Section "Monitor"
Identifier "monitor1"
Option "DPMS"
HorizSync 28-50
VertRefresh 60-85
EndSection

Section "Screen"
Identifier "screen0"
Device "dev0"
Monitor "monitor0"
DefaultDepth 16
SubSection "Display"
Depth 16
Modes "1024x768"
EndSubSection
EndSection

Section "Screen"
Identifier "screen1"
Device "dev1"
Monitor "monitor1"
DefaultDepth 16
SubSection "Display"
Depth 16
Modes "1024x768"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "Default Layout"
InputDevice "Generic Keyboard"
InputDevice "Generic Mouse"
Screen "screen0"
Screen "screen1" RightOf "screen0"
EndSection

Section "DRI"
Mode 0666
EndSection

Section "ServerFlags"
Option "Xinerama" "on"
EndSection
dual head xorg.conf:
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
RgbPath "/etc/X11/rgb"
ModulePath "/usr/lib/xorg/modules"
FontPath "/usr/share/fonts/X11/misc"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/share/fonts/X11/cyrillic"
FontPath "/usr/share/fonts/X11/100dpi/:unscaled"
FontPath "/usr/share/fonts/X11/75dpi/:unscaled"
FontPath "/usr/share/fonts/X11/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/share/fonts/X11/100dpi"
FontPath "/usr/share/fonts/X11/75dpi"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Section "Module"
Load "extmod"
Load "GLcore"
Load "dbe"
Load "dri"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "ru,us"
Option "XkbOptions" "grp:caps_toggle"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "PHL"
ModelName "PHILIPS 107E"
HorizSync 30.0 - 70.0
VertRefresh 50.0 - 160.0
Option "DPMS"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection

Section "Device"
Option "NoAccel" "true"
Identifier "Card0"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "Radeon RV100 QY [Radeon 7000/VE]"
BusID "PCI:0:20:0"
Screen 0
EndSection

Section "Device"
Option "NoAccel" "true"
Identifier "Card1"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "Radeon RV100 QY [Radeon 7000/VE]"
BusID "PCI:0:20:0"
Screen 1
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 16
SubSection "Display"
Depth 16
Modes "1024x768"
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "Card1"
Monitor "Monitor1"
DefaultDepth 16
SubSection "Display"
Depth 16
Modes "1024x768"
EndSubSection
EndSection

Section "ServerFlags"
Option "AllowMouseOpenFail" "true"
Option "DontVTSwitch" "true"
Option "DontZap" "true"
Option "DontZoom" "true"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
EndSection


[ view entry ] ( 582 views )   |  print article
xorg ati ES1000 with DRI 
xorg ati/radeon video driver for ES1000 has DRI disabled :-(

As a workaraound i changed ChipID in xorg.conf to "0x515a"

suggested by http://ubuntuforums.org/showpost.php?p= ... stcount=15
Section "Device"
Identifier "ATI Technologies Inc ES1000"
Driver "ati"
ChipID 0x515a
EndSection


[ view entry ] ( 829 views )   |  print article
date with unix timestamp 
date in unix timestamp: date +%s

convert unix timestamp to date: date --date "Jan 1, 1970 00:00:00 +0000 + $1 seconds"

set date with unix timestamp: date -s "Jan 1, 1970 00:00:00 +0000 + $1 seconds"


[ view entry ] ( 629 views )   |  print article
secure rsync 
I want to rsync on my local-host via ssh from a remote host without a ssh enabled root account but full access to the whole filesystem.

local-host:
ssh-keygen -t rsa
copy ~/.ssh/id_dsa.pub to remote-host:/home/rsyncuser/.ssh/authorized_keys

rsync files with ssh:
rsync -vaHxr --numeric-ids --delete --rsync-path=rsync_wrapper.sh \
-e "ssh -c arcfour -o Compression=no -x" \
rsyncuser@remote-host:REMOTEDIR LOCALDIR

remote-host (source of files to rsync):
groupadd -g 3001 rsyncuser
useradd -u 3001 -g rsyncuser -s /bin/bash -m rsyncuser
/home/rsyncuser/.ssh/authorized_keys:
from="192.168.0.2,",command="/home/rsyncuser/validate-rsync.sh"
ssh-dss 012345678...
limit access with from (optional).
On sucessfully ssh login command is executed.

/home/rsyncuser/validate-rsync.sh:
#!/bin/sh
case "$SSH_ORIGINAL_COMMAND" in
*\&*)
echo “Rejected”
;;
*\;*)
echo “Rejected”
;;
*\(*)
echo “Rejected”
;;
*\{*)
echo “Rejected”
;;
*\<*)
echo “Rejected”
;;
*\`*)
echo “Rejected”
;;
rsync\ --server*)
$SSH_ORIGINAL_COMMAND
;;
*)
echo "Rejected"
;;
esac
/usr/bin/rsync_wrapper.sh:
#!/bin/sh
/usr/bin/sudo /usr/bin/rsync "$@";
/etc/sudoers:
rsyncuser ALL = NOPASSWD: /usr/bin/rsync


[ view entry ] ( 654 views )   |  print article

<<First <Back | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Next> Last>>