Dependency
- Setup Timezone
- Initialized CentOS Server
Option
Script
# Setup Timezone
function isinstalled {
if yum list installed | grep "$@"; then
true
else
false
fi
}
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
if isinstalled "ntp"; then
echo "Install ntp .......... [${GREEN}OK${RESET}]";
else
yum install ntp -y;
mv /etc/localtime /etc/localtime.bak
ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
ntpd
chkconfig ntpd on
echo "Install ntp .......... [${GREEN}Installed${RESET}]";
fi
# Initialized CentOS Server
yum groupinstall "Development tools" -y
yum install nano wget -y
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel -y
yum install libjpeg-devel freetype-devel libpng-devel -y
yum install libxml2-devel libxslt-devel -y
yum install epel-release -y
setenforce 0
# TODO: disable
# nano /etc/selinux/config
# SELINUX=disabled
# Install SOCKS5 Proxy
cd /opt
wget http://downloads.sourceforge.net/ss5/ss5-3.8.9-8.src.rpm
yum install gcc.x86_64 rpm-build.x86_64 openldap-devel.x86_64 pam-devel.x86_64 openssl-devel.x86_64 -y
yum install libgssapi-devel -y
rpmbuild --rebuild ss5-3.8.9-8.src.rpm
cd ~
rpm -ivh rpmbuild/RPMS/x86_64/ss5-3.8.9-8.x86_64.rpm
cat <<EOT > /etc/init.d/ss5
#!/bin/sh
#
# chkconfig: 345 20 80
# description: This script takes care of starting \
# and stopping ss5
#
export SS5_SOCKS_PORT={{ SOCKS5_PORT }}
export SS5_SOCKS_USER={{ SOCKS5_USER }}
OS=`uname -s`
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/sbin/ss5 ] || exit 0
fi
# Test custom variables
test -f /etc/sysconfig/ss5 && . /etc/sysconfig/ss5
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting ss5... "
if [ $OS = "Linux" ]; then
daemon /usr/sbin/ss5 -t $SS5_OPTS
touch /var/lock/subsys/ss5
else
if [ $OS = "SunOS" ]; then
/usr/sbin/ss5 -t
touch /var/lock/subsys/ss5
else
/usr/local/sbin/ss5 -t
fi
fi
echo "done"
;;
stop)
# Stop daemon.
echo "Shutting down ss5... "
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
killproc ss5
rm -f /var/lock/subsys/ss5
else
killall ss5
fi
rm -f /var/run/ss5/ss5.pid
echo "done"
;;
reload)
# Reload configuration
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
echo -n "Reloading ss5... "
killproc ss5 -1
else
pkill -HUP ss5
fi
echo "done reload"
;;
restart)
# Restart daemon
echo -n "Restarting ss5... "
$0 stop
$0 start
;;
status)
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
status ss5
fi
;;
*)
echo "Usage: ss5 {start|stop|status|restart|reload}"
exit 1
;;
esac
EOT
cat <<EOT >> /etc/opt/ss5/ss5.conf
auth 0.0.0.0/0 - u
permit - 0.0.0.0/0 - 0.0.0.0/0 - - - - -
EOT
cat <<EOT >> /etc/opt/ss5/ss5.passwd
{{ SOCKS5_AUTH_USER }} {{ SOCKS5_AUTH_PASSWORD }}
EOT
chmod 750 /etc/opt/ss5/ss5.passwd
cat <<EOT > nano /etc/sysconfig/ss5
SS5_OPTS=" -m"
EOT
chkconfig ss5 on
service ss5 start