Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
bypanelcom committed Mar 25, 2018
1 parent 258febd commit 5b9adb8
Show file tree
Hide file tree
Showing 27 changed files with 268 additions and 280 deletions.
36 changes: 18 additions & 18 deletions addons.sh
Expand Up @@ -8,7 +8,7 @@
# https://oneinstack.com
# https://github.com/lj2007331/oneinstack

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
clear
printf "
#######################################################################
Expand Down Expand Up @@ -62,7 +62,7 @@ fi

# Check PHP Extensions
Check_PHP_Extension() {
[ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; }
[ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; }
[ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; }
}

Expand Down Expand Up @@ -90,7 +90,7 @@ Install_fail2ban() {
${python_install_dir}/bin/python setup.py install
if [ "${OS}" == "CentOS" ]; then
LOGPATH=/var/log/secure
/bin/cp files/redhat-initd /etc/init.d/fail2ban
/bin/cp files/redhat-initd /etc/init.d/fail2ban
sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban
sed -i 's@Starting fail2ban.*@&\n [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban
chmod +x /etc/init.d/fail2ban
Expand All @@ -99,7 +99,7 @@ Install_fail2ban() {
fi
if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
LOGPATH=/var/log/auth.log
/bin/cp files/debian-initd /etc/init.d/fail2ban
/bin/cp files/debian-initd /etc/init.d/fail2ban
sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban
sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban
chmod +x /etc/init.d/fail2ban
Expand All @@ -116,9 +116,9 @@ maxretry = 5
enabled = true
filter = sshd
action = iptables[name=SSH, port=$now_ssh_port, protocol=tcp]
logpath = $LOGPATH
logpath = $LOGPATH
EOF
cat > /etc/logrotate.d/fail2ban << EOF
cat > /etc/logrotate.d/fail2ban << EOF
/var/log/fail2ban.log {
missingok
notifempty
Expand All @@ -142,7 +142,7 @@ EOF
Uninstall_fail2ban() {
/etc/init.d/fail2ban stop
${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
}

Expand Down Expand Up @@ -171,9 +171,9 @@ What Are You Doing?
\t${CMSG} 4${CEND}. Install/Uninstall fileinfo PHP Extension
\t${CMSG} 5${CEND}. Install/Uninstall memcached/memcache
\t${CMSG} 6${CEND}. Install/Uninstall Redis
\t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
\t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
\t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
\t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
\t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
\t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
\t${CMSG}10${CEND}. Install/Uninstall fail2ban
\t${CMSG} q${CEND}. Exit
"
Expand Down Expand Up @@ -435,7 +435,7 @@ What Are You Doing?
./configure --with-php-config=${php_install_dir}/bin/php-config
make -j ${THREAD} && make install
popd
rm -rf swoole-${swoole_ver}
rm -rf swoole-${swoole_ver}
popd
echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
Check_succ
Expand All @@ -452,17 +452,17 @@ What Are You Doing?
if [[ "${PHP_main_ver}" =~ ^7\.[0-2]$ ]]; then
src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
tar xzf xdebug-${xdebug_ver}.tgz
tar xzf xdebug-${xdebug_ver}.tgz
unzip -q webgrind-master.zip
/bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
pushd xdebug-${xdebug_ver}
/bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
pushd xdebug-${xdebug_ver}
elif [[ "${PHP_main_ver}" =~ ^5\.[5-6]$ ]]; then
src_url=https://pecl.php.net/get/xdebug-2.5.5.tgz && Download_src
src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
tar xzf xdebug-2.5.5.tgz
tar xzf xdebug-2.5.5.tgz
unzip -q webgrind-master.zip
/bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
pushd xdebug-2.5.5
/bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
pushd xdebug-2.5.5
else
echo "${CWARNING}Need a PHP version >= 5.5.0 and <= 7.2.0${CEND}"
exit 1
Expand All @@ -471,7 +471,7 @@ What Are You Doing?
./configure --with-php-config=${php_install_dir}/bin/php-config
make -j ${THREAD} && make install
popd
rm -rf xdebug-${xdebug_ver}
rm -rf xdebug-${xdebug_ver}
popd
[ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
[ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
Expand Down
14 changes: 7 additions & 7 deletions backup.sh
Expand Up @@ -134,7 +134,7 @@ WEB_UPYUN_BK() {
fi
/usr/local/bin/upx put $PUSH_FILE /`date +%F`/Web_${W}_$(date +%Y%m%d_%H).tgz
if [ $? -eq 0 ]; then
/usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
/usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
[ -e "$PUSH_FILE" -a -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -rf $PUSH_FILE
fi
done
Expand All @@ -145,23 +145,23 @@ do
if [ "${DEST}" == 'local' ]; then
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_Local_BK
[ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_Local_BK
fi
fi
if [ "${DEST}" == 'remote' ]; then
echo "com:::[ ! -e "${backup_dir}" ] && mkdir -p ${backup_dir}" > config_bakcup.txt
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_Remote_BK
[ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_Remote_BK
./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
fi
fi
if [ "${DEST}" == 'oss' ]; then
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_OSS_BK
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_OSS_BK
[ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_OSS_BK
fi
fi
if [ "${DEST}" == 'cos' ]; then
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_COS_BK
[ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_COS_BK
fi
fi
if [ "${DEST}" == 'upyun' ]; then
[ -n "`echo ${backup_content} | grep -ow db`" ] && DB_UPYUN_BK
[ -n "`echo ${backup_content} | grep -ow web`" ] && WEB_UPYUN_BK
fi
fi
done
27 changes: 13 additions & 14 deletions backup_setup.sh
Expand Up @@ -8,7 +8,7 @@
# https://oneinstack.com
# https://github.com/lj2007331/oneinstack

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
clear
printf "
#######################################################################
Expand All @@ -34,9 +34,9 @@ while :; do echo
echo 'Please select your backup destination:'
echo -e "\t${CMSG}1${CEND}. Localhost"
echo -e "\t${CMSG}2${CEND}. Remote host"
echo -e "\t${CMSG}3${CEND}. Aliyun OSS"
echo -e "\t${CMSG}3${CEND}. Aliyun OSS"
echo -e "\t${CMSG}4${CEND}. Qcloud COS"
echo -e "\t${CMSG}5${CEND}. UPYUN(又拍云)"
echo -e "\t${CMSG}5${CEND}. UPYUN(又拍云)"
read -p "Please input a number:(Default 1 press Enter) " desc_bk
[ -z "${desc_bk}" ] && desc_bk=1
ary=(1 2 3 4 5 12 13 14 15 23 24 25 34 35 45 123 124 125 234 235 345 1234 1235 2345 12345)
Expand Down Expand Up @@ -116,7 +116,7 @@ if [ "${content_bk}" != '1' ]; then
websites=`ls ${wwwroot_dir}`
while :; do echo
echo "Please enter one or more name for website, separate multiple website names with commas: "
read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name
read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name
website_name=`echo ${website_name} | tr -d ' '`
[ -z "${website_name}" ] && website_name="`echo $websites | tr ' ' ','`"
W_tmp=0
Expand Down Expand Up @@ -180,9 +180,9 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then
echo 'Please select your backup datacenter:'
echo -e "\t ${CMSG}1${CEND}. cn-hangzhou-华东 1 (杭州) ${CMSG}2${CEND}. cn-shanghai-华东 2 (上海)"
echo -e "\t ${CMSG}3${CEND}. cn-qingdao-华北 1 (青岛) ${CMSG}4${CEND}. cn-beijing-华北 2 (北京)"
echo -e "\t ${CMSG}5${CEND}. cn-zhangjiakou-华北 3 (张家口) ${CMSG}6${CEND}. cn-huhehaote-华北 5(呼和浩特)"
echo -e "\t ${CMSG}5${CEND}. cn-zhangjiakou-华北 3 (张家口) ${CMSG}6${CEND}. cn-huhehaote-华北 5(呼和浩特)"
echo -e "\t ${CMSG}7${CEND}. cn-shenzhen-华南 1 (深圳) ${CMSG}8${CEND}. cn-hongkong-香港"
echo -e "\t ${CMSG}9${CEND}. us-west-美西 1 (硅谷) ${CMSG}10${CEND}. us-east-美东 1 (弗吉尼亚)"
echo -e "\t ${CMSG}9${CEND}. us-west-美西 1 (硅谷) ${CMSG}10${CEND}. us-east-美东 1 (弗吉尼亚)"
echo -e "\t${CMSG}11${CEND}. ap-southeast-亚太东南 1 (新加坡) ${CMSG}12${CEND}. ap-southeast-亚太东南 2 (悉尼)"
echo -e "\t${CMSG}13${CEND}. ap-southeast-亚太东南 3 (吉隆坡) ${CMSG}14${CEND}. ap-northeast-亚太东北 1 (日本)"
echo -e "\t${CMSG}15${CEND}. eu-central-欧洲中部 1 (法兰克福) ${CMSG}16${CEND}. me-east-中东东部 1 (迪拜)"
Expand Down Expand Up @@ -211,7 +211,7 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then
[ "${Location}" == '15' ] && Host=oss-eu-central-1-internal.aliyuncs.com
[ "${Location}" == '16' ] && Host=oss-me-east-1-internal.aliyuncs.com
[ "$(./include/check_port.py ${Host} 80)" == "False" ] && Host=`echo ${Host} | sed 's@-internal@@g'`
[ -e "/root/.ossutilconfig" ] && rm -f /root/.ossutilconfig
[ -e "/root/.ossutilconfig" ] && rm -f /root/.ossutilconfig
while :; do echo
read -p "Please enter the aliyun oss Access Key ID: " KeyID
[ -z "${KeyID}" ] && continue
Expand All @@ -233,7 +233,7 @@ fi

if [ `echo ${desc_bk} | grep -e 4` ]; then
[ ! -e "${python_install_dir}/bin/python" ] && Install_Python
[ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1
[ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1
while :; do echo
echo 'Please select your backup datacenter:'
echo -e "\t ${CMSG}1${CEND}. 北京一区(华北) ${CMSG}2${CEND}. 北京"
Expand All @@ -259,7 +259,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then
[ "${Location}" == '8' ] && region='na-toronto'
[ "${Location}" == '9' ] && region='eu-frankfurt'
while :; do echo
read -p "Please enter the Qcloud COS APPID: " APPID
read -p "Please enter the Qcloud COS APPID: " APPID
[ -z "${APPID}" ] && continue
echo
read -p "Please enter the Qcloud COS SecretId: " SecretId
Expand All @@ -268,7 +268,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then
read -p "Please enter the Qcloud COS SecretKey: " SecretKey
[ -z "$SecretKey" ] && continue
echo
read -p "Please enter the Qcloud COS bucket: " bucket
read -p "Please enter the Qcloud COS bucket: " bucket
[ -z "${bucket}" ] && continue
echo
${python_install_dir}/bin/coscmd config -u ${APPID} -a ${SecretId} -s $SecretKey -r $region -b ${bucket} >/dev/null 2>&1
Expand All @@ -293,17 +293,16 @@ if [ `echo ${desc_bk} | grep -e 5` ]; then
chmod +x /usr/local/bin/upx
fi
while :; do echo
read -p "Please enter the ServiceName: " ServiceName
read -p "Please enter the ServiceName: " ServiceName
[ -z "${ServiceName}" ] && continue
echo
read -p "Please enter the Operator: " Operator
read -p "Please enter the Operator: " Operator
[ -z "${Operator}" ] && continue
echo
read -p "Please enter the Password: " Password
read -p "Please enter the Password: " Password
[ -z "${Password}" ] && continue
echo
/usr/local/bin/upx login ${ServiceName} ${Operator} ${Password} >/dev/null 2>&1
/usr/local/bin/upx ls >/dev/null 2>&1
if [ $? = 0 ]; then
echo "${CMSG}ServiceName/Operator/Password OK${CEND}"
echo
Expand Down
1 change: 1 addition & 0 deletions include/alisql-5.6.sh
Expand Up @@ -37,6 +37,7 @@ Install_AliSQL56() {

if [ -d "${alisql_install_dir}/support-files" ]; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
echo "${CSUCCESS}AliSQL installed successfully! ${CEND}"
rm -rf alisql-${alisql_ver}
else
Expand Down

0 comments on commit 5b9adb8

Please sign in to comment.