Archive for the ‘bash scripting’ Category
oke, after u setup the vpn and you get it working:
enable telnet/ssh on synology box
login into synology
type ifconfig
you should see an pppx interface:
ppp0 Link encap:Point-to-Point Protocol
inet addr:192.168.1.44 P-t-P:192.168.1.99 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1396 Metric:1
RX packets:1819 errors:0 dropped:0 overruns:0 frame:0
TX packets:1372 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:1694061 (1.6 MiB) TX bytes:236202 (230.6 KiB)
you need the P-t-P ip: in this case is 192.168.1.99
vi /etc/ppp/ip-up
add at the end of file:
#added for vpn routes
case "${IPREMOTE}" in
192.168.1.99)
ip ro add 1.2.3.4/24 dev ${IFNAME}
ip ro add 2.3.4.0/24 dev ${IFNAME}
;;
esac
restart vpn from control panel:
you should see already the new routes:
nas> ip route show
192.168.1.99 dev ppp0 src 192.168.1.44
|ip of vpn server| via |default gw| dev eth0 src |ip of syno|
|local subnet|/24 dev eth0
1.2.3.4/24 dev ppp0
2.3.4.0/24 dev ppp0
default via |gateway| dev eth0
Posted by admin on July 10, 2013 at 10:39 am under bash, bash scripting, linux, networking.
Comment on this post.
Backup the partition table
sfdisk -d /dev/sda > /tmp/partitions.sda
Partition the disk
fdisk /dev/sda
Restore partition table after major mistake
sfdisk /dev/sda < /tmp/partitions.sda
Update /proc/partitions
partprobe /dev/sda
Posted by admin on September 19, 2010 at 12:25 am under bash, bash scripting, linux.
Comment on this post.
sort [options] file(s)
Common options
-r performs a reverse (descending) sort
-n performs a numeric sort
-f ignores (folds) case of characters in strings
-u (unique) removes duplicate lines in output
-t c uses c as a field separator
-k X sorts by c-delimited field X
Can be used multiple times
Posted by admin on September 19, 2010 at 12:19 am under bash, bash scripting, linux.
Comment on this post.
Display specific columns of file or STDIN data
cut -d: -f1 /etc/passwd
grep root /etc/passwd | cut -d: -f7
Use -d to specify the column delimiter (default is TAB)
Use -f to specify the column to print
Use -c to cut by characters
cut -c2-5 /usr/share/dict/words
Posted by admin on September 19, 2010 at 12:19 am under bash, bash scripting, linux.
Comment on this post.
You may check first what is the path of sendmail:
whereis sendmail
or php -i | grep sendmail
move /usr/sbin/sendmail
to something like /usr/sbin/sendmail.or
vi /usr/sbin/sendmail
put the code below:
#!/usr/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/formmail.log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n";
}
else {
print INFO "$date - $PWD - @info\n";
}
my $mailprog = '/usr/sbin/sendmail.or';
foreach (@ARGV) {
$arg="$arg" . " $_";
}
open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);
chmod a+x /usr/sbin/sendmail
touch /var/log/formmail.log
and chmod 777 /var/log/formmail.log
that should be all.
Posted by admin on February 19, 2010 at 2:34 pm under bash scripting, email, linux, php, security.
Comment on this post.
cat /etc/passwd | awk -F: '{print $1}' | while read line; do echo $line; crontab -l -u $line; done
Posted by admin on February 2, 2010 at 5:05 pm under bash, bash scripting, linux.
Comment on this post.
http://www.linuxscrew.com/2009/12/21/best-of-linux-cheat-sheets/
Posted by admin on February 1, 2010 at 8:55 pm under apache, bash, bash scripting, dns, email, linux, mysql, php, security, virtualhost.
Comment on this post.
ls | while read line; do x=$(echo $line |egrep -o .*mp3); mv $line $x ;done
Posted by admin on February 1, 2010 at 2:55 pm under bash scripting, linux.
Comment on this post.
#!/bin/sh
SERVICE='named'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
cat /dev/null
else
echo "$SERVICE is not running... starting"
/etc/init.d/$SERVICE restart | mail -s "$SERVICE restarted" email@domain.tld
fi
p.s. do not name the script as the service 🙂
Posted by admin on February 1, 2010 at 2:54 pm under bash scripting, linux.
Comment on this post.