/etc/network/interfaces
:
auto wan
iface wan inet manual
up ifup eth0=eth0-static
post-up /etc/network/checkConnectivity.sh eth0 192.168.0.1 10.10.0.2
iface eth0 inet manual
#static eth0 config
iface eth0-static inet static
address 192.168.0.97
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1 10.10.0.2
dns-search example.net
#dhcp eth0 config
iface eth0-dhcp inet dhcp
/etc/network/checkConnectivity.sh
:
#!/bin/bash
nif=${1}
shift
sleep 1
for i in ${@}; do
ping -c 2 ${i} \
&& exit 0
done
# if nothing responds
ifdown ${nif}
ifup ${nif}=${nif}-dhcp
manually override:
ifup eth0=eth0-static
ifup eth0=eth0-dhcp
A simple classless PHP regex router function
https://gist.github.com/iiidefix/ea2ba83b51045ed667eaaa40d60cba88
Router.php
.htaccess
Assuming the following Data:
- Webdav URL: http://example.com/webdav
- Username: user
- Password: pass
Actions
Reading Files/Folders
curl 'http://example.com/webdav'
Creating new Folder
curl -X MKCOL 'http://example.com/webdav/new_folder'
Uploading File
curl -T '/path/to/local/file.txt' 'http://example.com/webdav/test/new_name.txt'
Renaming File
curl -X MOVE --header 'Destination:http://example.org/webdav/new.txt' 'http://example.com/webdav/old.txt'
Deleting Files/Folders
File:
curl -X DELETE 'http://example.com/webdav/test.txt'
Folder:
curl -X DELETE 'http://example.com/webdav/test'
List Files in a Folder
curl -i -X PROPFIND http://example.com/webdav/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
<a:prop><a:resourcetype/></a:prop>
</a:propfind>
end
Continue reading WebDAV with cURL →
View partition table of disk.img:
fdisk -lu disk.img
Disk disk.img: 1.3 GiB, 1361051648 bytes, 2658304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6f92008e
Device Boot Start End Sectors Size Id Type
disk.img1 8192 131071 122880 60M c W95 FAT32 (LBA)
disk.img2 131072 2658303 2527232 1.2G 83 Linux
Mount partition by using start multiplied by sector size as offset
mount -o loop,offset=$((131072 * 512)) disk.img /mnt
$hbas = Get-VMHostHba -VMHost $vmHost -Type FibreChannel
foreach ($hba in $hbas) {
$wwpn = (&{param ($s) for($i=14;$i -gt 0;$i-=2) {$s=$s.insert($i,":")} return $s}("{0:x}" -f $hba.PortWorldWideName))
Write-Host "`t" $hba.Device "|" $hba.model "|" "World Wide Port Name:" $wwpn
}
random code and config snippets by iiidefix & friends