Difference between revisions of "SMEOnffLine: Instalasi Beberapa Batch File Bermanfaat"

From OnnoWiki
Jump to navigation Jump to search
Line 1: Line 1:
 
==mirrorbuild.sh==
 
==mirrorbuild.sh==
  
 +
mkdir /var/data/mirrorkeyring
 +
gpg --no-default-keyring --keyring /var/data/mirrorkeyring/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
 
  vi /usr/local/bin/mirrorbuild.sh
 
  vi /usr/local/bin/mirrorbuild.sh
  

Revision as of 07:59, 25 January 2010

mirrorbuild.sh

mkdir /var/data/mirrorkeyring
gpg --no-default-keyring --keyring /var/data/mirrorkeyring/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
vi /usr/local/bin/mirrorbuild.sh
#### Start script to automate building of Ubuntu mirror #####
## THE NEXT LINE IS NEEDED THE REST OF THE LINES STARTING WITH A # CAN BE DELETED

#!/bin/bash

## Setting variables with explanations.

#
# Don't touch the user's keyring, have our own instead
#
export GNUPGHOME=/var/data/mirrorkeyring

# Arch=         -a      # Architecture. For Ubuntu can be i386, powerpc or amd64.
# sparc, only starts in dapper, it is only the later models of sparc.
#
arch=i386

# Minimum Ubuntu system requires main, restricted
# Section=      -s      # Section (One of the following - main/restricted/universe/multiverse).
# You can add extra file with $Section/debian-installer. ex: main/debian-installer,universe/debian-installer,multiverse/debian-installer,restricted/debian-installer
#
section=main,restricted,universe,multiverse

# Release=      -d      # Release of the system (Dapper, Edgy, Feisty, Gutsy, Hardy, Intrepid), and the -updates  and -security ( -backports can be  added if desired)
#
# release=jaunty,jaunty-security,jaunty-updates
# release=karmic
# release=karmic,karmic-security,karmic-updates
release=karmic,karmic-security,karmic-updates,karmic-backports,karmic-proposed

# Server=       -h      # Server name, minus the protocol and the path at the end
# CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia  ca. in Canada.
# This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed.
#
# server=opensource.telkomspeedy.com:5432
# server=dl2.foss-id.web.id
server=125.160.17.22

# Dir=          -r      # Path from the main server, so http://my.web.server/$dir, Server dependant
#
inPath=ubuntu

# Proto=        -e      # Protocol to use for transfer (http, ftp, hftp, rsync)
# Choose one - http is most usual the service, and the service must be avaialbe on the server you point at.
#
proto=http

# Outpath=              # Directory to store the mirror in
# Make this a full path to where you want to mirror the material.
#
outPath=/var/www/ubuntu

# The --nosource option only downloads debs and not deb-src's
# The --progress option shows files as they are downloaded
# --source \ in the place of --no-source \ if you want sources also.
# --nocleanup  Do not clean up the local mirror after mirroring is complete. Use this option to keep older  repository
# Start script
#
debmirror       -a $arch \
                --no-source \
                -s $section \
                -h $server \
                -d $release \
                -r $inPath \
                --progress \
                -e $proto \
                $outPath

#### End script to automate building of Ubuntu mirror ####

updatewiki.sh

vi /usr/local/bin/updatewiki.sh 
rm -Rf /var/data/library/datawiki/*
rm -Rf /usr/local/src/var
rm -Rf /usr/local/src/wikidb*
wget http://125.160.17.21/speedyorari/view.php?file=datawiki/wikidb.sql.gz -O /var/data/library/datawiki/wikidb.sql.gz
wget http://125.160.17.21/speedyorari/view.php?file=datawiki/images.tar.gz -O /var/data/library/datawiki/images.tar.gz
cp -Rf /var/data/library/datawiki/* /usr/local/src
cd /usr/local/src
tar zxvf images.tar.gz
gunzip wikidb.sql.gz
cp -Rf /usr/local/src/var/www/html/wiki/images /var/www/wiki/
chown -Rf www-data.www-data /var/www/wiki
/etc/init.d/mysql restart
mysqladmin --user=root --password=123456 --force drop mediawiki
mysqladmin --user=root --password=123456 create mediawiki
mysql -u mediawiki -pmediawiki mediawiki < /var/www/wiki/maintenance/tables.sql
mysql -u mediawiki -pmediawiki mediawiki < /usr/local/src/wikidb.sql
/etc/init.d/mysql restart
cd /var/www/wiki/maintenance
php update.php
/etc/init.d/mysql restart
chown -Rf nobody.nogroup /var/data &
chmod -Rf 777 /var/data &

nobody.sh

vi /usr/local/bin/nobody.sh 
chown -Rf nobody.nogroup /var/data &
chmod -Rf 777 /var/data &

aktifkanproxy.sh

vi /usr/local/bin/aktifkanproxy.sh 
#!/bin/bash

# From: AHK <akuhon@kompas.com>
# To: linux-admin@linux.or.id

# Save this file and activate through # file_name start
# and de-activate through # file_name stop

# This firewall-script can be used for workstation, laptop, router
# or server that are not running network service (such as web server, ftp
# server etc)

# change the parameter UPLINK with Interface device to the Internet.
# In our case WLAN router with NIC wlan0 connected to the Internet
# and LAN connection with eth0.
# if you use dial-up modem, you might use ppp0 as your UPLINK

UPLINK="eth1"

# if you run the gateway as router and forward IP packet between eth devices
# please fill .yes., if not, please fill .no.

ROUTER="yes"

# Please change 202.150.10.45 to your static IP address of UPLINK device.
# For those who use dial-up or dynamic IP, please enter .dynamic.

# NAT="192.168.1.100"

NAT="dynamic" 

# please list all network interfaces including eth devices
# as well as dial-up interface such as ppp0

INTERFACES="lo eth0 eth1 eth2"

if [ "$1" = "start" ]
  then
  echo "Activate Firewall ..... "
  /sbin/iptables -F
  /sbin/iptables -P INPUT DROP
  /sbin/iptables -A INPUT -p tcp -i eth0 --destination-port 25 -s ! 192.168.0.1  -j DROP
  /sbin/iptables -A INPUT -p tcp -i eth1 --destination-port 25 -s ! 192.168.0.1  -j DROP

  /sbin/iptables -A INPUT -i ! ${UPLINK} -j ACCEPT
  /sbin/iptables -A INPUT -i ${UPLINK} -p tcp -s 0/0 --dport 25 -j ACCEPT
  /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  /sbin/iptables -A INPUT -p tcp -i ${UPLINK} -j REJECT --reject-with tcp-reset
  /sbin/iptables -A INPUT -p udp -i ${UPLINK} -j REJECT --reject-with icmp-port-unreachable
 
  /sbin/iptables -A FORWARD -p tcp --destination-port 25 -s ! 192.168.0.1  -j DROP

# block bad sites

  /sbin/iptables -I INPUT -s 68.178.211.34 -j DROP
  /sbin/iptables -I INPUT -d 68.178.211.34 -j DROP 

  /sbin/iptables -I INPUT -s 64.27.5.168 -j DROP
  /sbin/iptables -I INPUT -d 64.27.5.168 -j DROP

# turn off packet spoofing in all interfaces
for x in ${INTERFACES}
  do
    echo 1 > /proc/sys/net/ipv4/conf/${x}/rp_filter
  done 

if [ "$ROUTER" = "yes" ]
  then
  # Activate IP forwarding at router
    echo 1 > /proc/sys/net/ipv4/ip_forward
if [ "$NAT" = "dynamic" ]
  then
  # Dynamic IP address, activate Masquerading
    echo "Activate Masquerading (Dynamic IP) ...."
    /sbin/iptables -t nat -A POSTROUTING -o ${UPLINK} -j MASQUERADE
elif [ "$NAT" != "" ]
  then
  # Static IP address use source NAT
  echo "Activate SNAT (static IP) ...."
  /sbin/iptables -t nat -A POSTROUTING -o ${UPLINK} -j SNAT --to ${NAT}
fi 

# echo "Activate Port Forwarding .."
# /sbin/iptables -t nat -A PREROUTING -i ${UPLINK} -m multiport -p tcp \
# --dport 25 -d ${NAT} -j DNAT --to 192.168.0.1:25
# /sbin/iptables -A FORWARD -i ${UPLINK} -m multiport -p tcp -d 192.168.0.1 \
#  --dport 25 -j ACCEPT 

fi
  elif [ "$1" = "stop" ]
    then
      echo "Deactivate Firewall ..."
      /sbin/iptables -F INPUT
      /sbin/iptables -P INPUT ACCEPT
      /sbin/iptables -F FORWARD
      /sbin/iptables -P FORWARD ACCEPT
      /sbin/iptables -F OUTPUT
      /sbin/iptables -P OUTPUT ACCEPT
      # Turn off NAT or MASQUERADING
      /sbin/iptables -t nat -F POSTROUTING
fi 


Pranala Menarik