#!/bin/sh ## blog: https://111111.online if [[ $EUID -ne 0 ]]; then clear echo "Error: This script must be run as root!" 1>&2 exit 1 fi timedatectl set-timezone Asia/Shanghai v2path=$(cat /dev/urandom | head -1 | md5sum | head -c 6) v2uuid=$(cat /proc/sys/kernel/random/uuid) install_ssl(){ if [ -f "/usr/bin/apt-get" ];then isDebian=`cat /etc/issue|grep Debian` if [ "$isDebian" != "" ];then apt install -y net-tools sleep 3s else apt install -y net-tools sleep 3s fi else yum install -y epel-release yum install -y net-tools sleep 3s fi isPort=`netstat -ntlp| grep -E ':80 |:443 '` if [ "$isPort" != "" ];then clear echo " ================================================== " echo " 80或443端口被占用,请先释放端口再运行此脚本" echo echo " 端口占用信息如下:" echo $isPort echo " ================================================== " exit 1 fi echo "====输入已经DNS解析好的域名====" read domain if [ -f "/usr/bin/apt-get" ];then isDebian=`cat /etc/issue|grep Debian` if [ "$isDebian" != "" ];then apt install -y snapd snap install core; snap refresh core snap install --classic certbot ln -s /snap/bin/certbot /usr/bin/certbot echo "Y" | certbot certonly --renew-by-default --register-unsafely-without-email --standalone -d $domain echo -e "0 2 1 * * /usr/bin/certbot renew --pre-hook \"service nginx stop\" --post-hook \"service nginx start\"" >> /var/spool/cron/crontabs/root systemctl restart cron.service sleep 3s else apt install -y certbot echo "A" | certbot certonly --renew-by-default --register-unsafely-without-email --standalone -d $domain echo -e "0 2 1 * * /usr/bin/certbot renew --pre-hook \"service nginx stop\" --post-hook \"service nginx start\"" >> /var/spool/cron/crontabs/root systemctl restart cron.service sleep 3s fi else yum install -y certbot echo "Y" | certbot certonly --renew-by-default --register-unsafely-without-email --standalone -d $domain echo -e "0 2 1 * * /usr/bin/certbot renew --pre-hook \"service nginx stop\" --post-hook \"service nginx start\"" >> /var/spool/cron/root systemctl restart crond.service sleep 3s fi } install_nginx(){ if [ -f "/usr/bin/apt-get" ];then isDebian=`cat /etc/issue|grep Debian` if [ "$isDebian" != "" ];then apt install -y build-essential libtool libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev sleep 3s else apt install -y build-essential libtool libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev sleep 3s fi else yum install -y gcc gcc-c++ zlib zlib-devel openssl openssl-devel pcre-devel sleep 3s fi wget https://nginx.org/download/nginx-1.21.1.tar.gz -O - | tar -xz cd nginx-1.21.1 ./configure --prefix=/etc/nginx \ --sbin-path=/usr/sbin/nginx \ --modules-path=/usr/lib/nginx/modules \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --with-http_v2_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_sub_module \ --with-stream \ --with-stream_ssl_module make && make install cd .. rm -rf nginx-1.21.1 cat >/lib/systemd/system/nginx.service</etc/nginx/nginx.conf</usr/local/etc/v2ray/config.json</usr/local/etc/v2ray/client.json</etc/shadowsocks-libev/config.json</etc/systemd/system/shadowsocks.service<