Setup OpenVPN

shell scripts No Comments »

Setup OpenVPN 2.0 with LZO compression library

cd /usr/local/src
wget http://oberhumer.com/opensource/lzo/download/lzo-1.08.gz
cd lzo-1.08
./configure
make
make check
make test
make install
# export LD_LIBRARY_PATH=/usr/local/lib
cd /usr/local/src
wget http://openvpn.net/release/openvpn-2.0.tar.gz
tar xzf openvpn-2.0.tar.gz
cd openvpn-2.0
./configure
make
make install

# Perform loopback tests
./openvpn –genkey –secret key
./openvpn –test-crypto –secret key

load TUN/TAP kernel module
modprobe tun
lsmod|grep tun
./openvpn –cd /etc/openvpn –config local.conf
 
cat >>/etc/rc.d/rc.local
if [ -x /etc/rc.d/rc.openvpn ]; then
 . /etc/rc.d/rc.openvpn
fi

EOF

RedHat 9 network settings

shell scripts No Comments »


#
# RedHat Linux 9 Server
# Network Setup
#

cat >/etc/sysconfig/network
NETWORKING=yes
HOSTAME=homebox
GATEWAY=192.168.30.254
EOF

cat >/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.30.1
NETMASK=255.255.255.0
GATEWAY=80.98.111.254
EOF

cat >/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
EOF

iptables firewall script

Firewall scripts, shell scripts No Comments »


#!/bin/bash

# firewall script using iptables
# Platform: Red Hat Linux 9 (Shrike)
# Author: webHauser
# Created: 2005.08.10.

IPTABLES="/sbin/iptables"
LAN="eth1"
WAN="eth0"

# Flush rules and delete all user chains
$IPTABLES -t filter -F
$IPTABLES -t filter -X
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -F
$IPTABLES -X

# Set default policies
$IPTABLES --policy INPUT DROP
$IPTABLES --policy OUTPUT DROP
$IPTABLES --policy FORWARD DROP

# enable masquerading to allow LAN internet access
$IPTABLES -t nat -A POSTROUTING -o $WAN -j MASQUERADE

# Forward all packets from internal network to eth0 (the internet).
$IPTABLES -A FORWARD -i $LAN -o $WAN -j ACCEPT
# Forward packets that are part of existing and related connections from eth0 to eth1.
$IPTABLES -A FORWARD -i $WAN -o $LAN -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow unlimited traffic on the loopback interface
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT

# Previously initiated and accepted exchanges bypass rule checking
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow ICMP echo requests on LAN interface
$IPTABLES -A INPUT -i $LAN -p icmp --icmp-type echo-request -j ACCEPT

# Allow incoming port 22 (ssh) connections on LAN interface
$IPTABLES -A INPUT -i $LAN -p tcp --destination-port 22 -m state --state NEW -j ACCEPT

# Allow DNS resolution on all interfaces
$IPTABLES -A INPUT -p udp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -p tcp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -p udp --destination-port 53 -m state --state NEW -j ACCEPT
$IPTABLES -A FORWARD -p tcp --destination-port 53 -m state --state NEW -j ACCEPT

# Allow ntp synchronization
$IPTABLES -A INPUT -i $WAN -p udp --destination-port 123 -m state --state NEW -j ACCEPT

# Allow OpenVPN Port and VLAN tunnel
$IPTABLES -A INPUT -p udp --destination-port 1194 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -p tcp --destination-port 1194 -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -i tun+ -p udp -m state --state NEW -j ACCEPT
$IPTABLES -A INPUT -i tun+ -p tcp -m state --state NEW -j ACCEPT
/sbin/iptables-save > /root/iptables-new

Startup script for Tomcat Servlet Engine

shell scripts, Java No Comments »

Example shell script usage:

  • /etc/rc.d/tomcat start
  • /etc/rc.d/tomcat stop
  • /etc/rc.d/tomcat restart


#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between RedHat Tomcat RPM and Chris Bush scripts
# Tomcat name :)
TOMCAT_PROG=tomcat
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z “$TOMCAT_USER” ]; then
 TOMCAT_USER=”tomcat”
fi
RETVAL=0
# start and stop functions
start() {
    echo -n “Starting tomcat: ”
    chown -R $TOMCAT_USER:$TOMCAT_USER /usr/java/jakarta-tomcat/*
    chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
    su -l $TOMCAT_USER -c ‘/usr/java/jakarta-tomcat/bin/startup.sh’
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
    return $RETVAL
}
stop() {
    echo -n "Stopping tomcat: "
    su -l $TOMCAT_USER -c '/usr/java/jakarta-tomcat/bin/shutdown.sh'
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
}
#    rm -rf /usr/java/jakarta-tomcat/work/*

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        # Ugly hack
        # We should really make sure tomcat
        # is stopped before leaving stop
        sleep 2
        start
        ;;
  *)
        echo "Usage: $0 start|stop|restart"
        exit 1
esac
exit $RETVAL

Windows XP command line shell

shell scripts No Comments »


netstat -a ; hálózati kapcsolatok
nbtstat -c ; view netbios cache
nbtstat -s ; view connections

net view  ; Windows számítógépek a NetBios hálózatban
net user  ; Hálózati felhasználók
net config server ; szerver konfig
net config workstation ; munkaállomás konfig
net share  ; megosztott mappák
net use \\star  ; connect to computer star in a NetBios network

Installing a new hard disk

shell scripts No Comments »

#!/bin/sh

if [ ! -e /mnt/newhd ]; then
   mkdir /mnt/newhd
fi
mount -t vfat /dev/hdc1 /mnt/newhd
cd /mnt/newhd

echo Az uj hd rendben.

GNU/Debian Linux install

shell scripts No Comments »


1 ln -s /usr/home home
2 cd /
3 cp -p menu.lst menu.lst~
4 cd /
5 pw tss
6 passwd tss
7 cd /
8 cd /
9 df -h
10 cd /
11 mc
12 cd /
13 mc
14 uname -a
15 apt-get kernel-source-2.4.27
16 apt-get install kernel-source-2.4.27
17 apt-get update
18 apt-get upgrade
19 apt-get update
20 apt-get upgrade
21 df -h
22 apt-get install kernel-image-2.4.27-2-686
23 cd /
24 df -h
25 cd /
26 uname -a
27 mc
28 cd /
29 shutdown -r now
30 chmod 755 list-apt~lled.sh
31 ./list-apt~lled.sh
32 ./list-apt~lled.sh
33 apt-get --purge remove kernel-image-2.4.27-3-386
34 ./list-apt~lled.sh
35 ./list-apt~lled.sh
36 ./list-apt~lled.sh
37 mv list-apt~lled.sh list-apts-installed.sh
38 ./list-apts-installed.sh
39 locate mysql
40 updatedb
41 locate mysql
42 locate mysql/data
43 locate mysql/mysql
44 ln -s /home/mysql mysql
45 chown mysql:mysql mysql
46 ./list-apts-installed.sh
47 ./list-apts-installed.sh
48 ./list-apts-installed.sh
49 ./list-apts-installed.sh
50 mc
51 cd /
52 cd /
53 mc
54 apt-get install qmail
55 /etc/init.d/qmail start
56 /etc/init.d/qmail stop
57 /etc/init.d/qmail start
58 cd /
59 mc
60 cd /
61 /etc/init.d/qmail start
62 /etc/init.d/qmail stop
63 /etc/init.d/qmail start
64 ping yahoo.com
65 cd /
66 mc
67 ping yahoo.com
68 cd /
69 mc
70 ps -aux | grep qmail
71 ps -aux | grep bind
72 cd /
73 mc
74 cd /
75 mc
76 exit
77 uname -a
78 cd /
79 apt-get update
80 apt-get upgrade
81 apt-get autoclean
82 apt-get autoclean
83 cd /
84 cd /home/tss
85 mc
86 cd /
87 apt-get install apt-show-versions
88 mc
89 cd /
90 apt-get update
91 apt-get upgrade
92 cd /
93 mc
94 mc
95 cd /
96 apt-get --purge remove libapache2-mod-php4
97 apt-get --purge remove php4-common
98 apt-get install php5
99 /etc/init.d/apache2 restart
100 apt-get install libapache2-mod-php5
101 apt-get --purge remove apache-common
102 /etc/init.d/apache2 restart
103 apt-get install php5-apc
104 apt-get install php5-cli
105 apt-get install php5-dev
106 apt-get install php5-gd
107 apt-get install php5-mysql
108 apt-get install php5-pear
109 apt-get install mysql-server-5.0
110 /etc/init.d/apache2 restart
111 /etc/init.d/
112 /etc/init.d/mysql stop
113 cd /
114 apt-get update
115 apt-get update
116 apt-get upgrade
117 cd /
118 /etc/init.d/mysql start
119 /etc/init.d/apache2 restart
120 cd /
121 apt-get autoclean
122 apt-get autoclean
123 apt-get --purge remove exim4-base
124 apt-get --purge remove exim4-config
125 cd /
126 mc
127 shutdown -r now
128 wget http://puzzle.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.8.2.4.tar.bz2
129 mv phpinfo.php ..
130 chown root:www-data config.inc.php
131 chmod 640 config.inc.php
132 cd /
133 mc
134 uname -a
135 uptime
136 ping yahoo.com
137 ping gal6.com
138 cd /
139 mc
140 cd /var/www/phpmyadmin
141 touch config.inc.php
142 pico -w config.inc.php
143 mc
144 cd /
145 mc
146 uname -a
147 uptime
148 shutdown -r now
149 grep -R chello *
150 ./list-apts-installed.sh
151 cd /
152 apt-get update
153 ping yahoo.com
154 cd /
155 mc
156 cd /
157 mc
158 ping yahoo.com
159 apt-get update
160 apt-get upgrade
161 apt-get install php5-mysqli
162 /etc/init.d/apache2 restart
163 dpkg-statoverride --list
164 dpkg-statoverride --help
165 dpkg-statoverride --list
166 cd /
167 apt-get update
168 apt-get update
169 apt-get update
170 apt-get upgrade
171 cd /
172 apt-get autoclean
173 cd /
174 mc
175 cd /
176 apt-get autoclean
177 cd /
178 mc
179 df -h
180 mc
181 cd /
182 mc
183 exit
184 cd /
185 mc
186 exit
187 cd /
188 apt-get update
189 apt-get upgrade
190 apt-get update
191 apt-get upgrade
192 apt-get update
193 apt-get upgrade
194 cd /
195 uname -a
196 uptime
197 cd /
198 mc
199 exit
200 cd /
201 apt-get update
202 apt-get upgrade
203 apt-get update
204 apt-get upgrade
205 cd /
206 uname -a
207 uptime
208 exit

WebSite Powered by webHauser
Entries RSS Comments RSS Login