#! /bin/bash # $author: twfcc@twitter # $PROG: stiny.sh # $Usage: $0 {-n|-s} # description: install HTTPS/SSL proxy on [NAT IPv4 Share|Dedicated IPv4] VPS(OpenVZ) # Public Domain use as your own risk! # Works on Debian 7 and Ubuntu 14.04 only trap cleanup INT cleanup(){ mv -f /etc/tinyproxy.conf.bak /etc/tinyproxy.conf 2> /dev/null mv -f /etc/default/stunnel4.bak /etc/default/stunnel4 2> /dev/null apt-get remove tinyproxy -y apt-get remove stunnel -y rm -f "$HOME/publickey.pem" 2> /dev/null rm -f "$HOME/privatekey.pem" 2> /dev/null rm -f "$HOME/publickey.crt" 2> /dev/null rm -f /etc/stunnel/stunnel.conf 2> /dev/null exit 1 } if [ $UID -ne 0 ] ; then echo "You must be root to execute this script." >&2 exit 1 fi [ $(pwd) != "/root" ] && cd "$HOME" case "$1" in -n) flag=0 ;; -s) flag=1 ;; *) echo "Usage: ${0##*/} {-n|-s}" >&2 ; echo "-n : install HTTPS/SSL proxy on NAT IPv4 Share VPS." >&2 ; echo "-s : install HTTPS/SSL proxy on Dedicated IPv4 VPS." >&2 ; exit 1 ;; esac tinyproxy_install(){ local cfg apt-get install tinyproxy -y [ $? -eq 0 ] && cd "/etc" || { echo "Install tinyproxy failed." >&2 ; exit 1 ; } cfg="tinyproxy.conf" [ -f "$cfg" ] && mv -f "$cfg" "${cfg}.bak" 2> /dev/null cat >"$cfg"< /etc/stunnel/stunnel.pem cat publickey.pem > publickey.crt } cat >stunnel.conf<&2 cleanup fi exit 0