#!/bin/sh if ! mount -t cifs | grep -q `cat /root/file_server` then mount -t cifs -o uid=apache,gid=apache,iocharset=utf8,noserverino,credentials=/root/.cifscreds `cat /root/file_server` /var/www fi
//192.168.0.2/Projects
username=developvm
password=secretpass
[Tue Oct 20 10:44:28.417589 2015] [core:crit] [pid 9632] (5)Input/output error: [client 192.168.1.5:60666] AH00529: /var/www/project/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/project/' is executable, referer: http://192.168.1.102/script.php
[Tue Oct 20 10:44:28.418762 2015] [core:error] [pid 9555] (5)Input/output error: [client 192.168.1.5:60670] AH00132: file permissions deny server access: /var/www/project/css/main/layout-main.css, referer: http://192.168.1.102/script.php
#!/bin/sh rm /etc/httpd/conf.d/vhosts/* rm /etc/hosts echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' >> /etc/hosts echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts for D in `find /var/www -maxdepth 1 -mindepth 1 -type d -printf '%f\n'` do echo '<VirtualHost *:80>' >> /etc/httpd/conf.d/vhosts/$D.conf echo "ServerName $D.wde" >> /etc/httpd/conf.d/vhosts/$D.conf echo "ServerAlias *.$D.wde" >> /etc/httpd/conf.d/vhosts/$D.conf echo "DocumentRoot /var/www/$D" >> /etc/httpd/conf.d/vhosts/$D.conf if [[ $D == *"bitrix"* ]] then echo 'php_admin_value mbstring.func_overload 2' >> /etc/httpd/conf.d/vhosts/$D.conf echo 'php_admin_value mbstring.internal_encoding UTF-8' >> /etc/httpd/conf.d/vhosts/$D.conf echo 'php_admin_value max_input_vars 10001' >> /etc/httpd/conf.d/vhosts/$D.conf echo 'php_admin_value pcre.recursion_limit 1000' >> /etc/httpd/conf.d/vhosts/$D.conf fi echo "</VirtualHost>" >> /etc/httpd/conf.d/vhosts/$D.conf echo "127.0.0.1 $D.wde" >> /etc/hosts done systemctl restart httpd.service
192.168.1.166 wde
192.168.1.166 site1.wde
192.168.1.166 site2.wde
... ..
#!/bin/sh SCRIPT_DIR=`dirname $0` source $SCRIPT_DIR/utils.sh #menu actions act_net () { nmtui ; } act_folder () { $SCRIPT_DIR/mount_cfg.sh ; } act_flushvhosts () { $SCRIPT_DIR/flush_vhosts.sh ; } act_reboot () { read -p "System is going to reboot, are u sure? (y/N) " key ; if [ $key = "y" ]; then systemctl reboot ; exit fi key= } act_shutdown () { read -p "System is going down, are u sure? (y/N) " key ; if [ $key = "y" ]; then systemctl halt ; exit fi key= } themenu () { clear server_uptime mnt_detect echo "====================================================================" echo "======================= WELCOME to CENTOS WDE!!! ===================" echo "====================================================================" echo "======================== wish you happy coding =====================" echo "====================================================================" echo -e "System time: "$curtime"\tUptime:"$uptime; echo ; echo -e "Mounted folder: "$MNT; echo ; echo "=========================== network info ===========================" echo "`ifconfig -a`" echo ; echo `grep nameserver /etc/resolv.conf` echo ; echo "`route -n`" echo ; echo "====================== current vhosts configs ======================" echo "`ls -1 /etc/httpd/conf.d/vhosts/`" echo ; echo "====================================================================" echo "========================= Available actions: =======================" echo -e "\t\tConfigure ${FG_UN}net${NORM}" echo -e "\t\tConfigure mounted ${FG_UN}folder${NORM}"; echo -e "\t\t${FG_UN}Flush${NORM} virtual hosts"; echo -e "\t\t${FG_UN}Reboot${NORM}"; echo -e "\t\t${FG_UN}Shutdown${NORM}"; echo echo "Type underlined chars(lowercase) and press ENTER or just ENTER to refresh"; echo "Type Ctrl+C to exit to shell"; echo "===================================================================="; } while true do themenu read answer case $answer in "net") act_net;; "folder") act_folder;; "flush") act_flushvhosts;; "reboot") act_reboot;; "shutdown") act_shutdown;; *) echo 'No action found! Refreshing...'; sleep 1; continue;; esac done
#!/bin/sh set -o pipefail mnt_dir="/var/www" if [ "$interactive" != 'no' ]; then #cursor movements CU_RIGHT=$(tput hpa $(tput cols))$(tput cub 7) #background colors BG_BLACK=$(tput setab 1) BG_RED=$(tput setab 1) BG_GREEN=$(tput setab 2) BG_YELLOW=$(tput setab 3) BG_BLUE=$(tput setab 4) BG_PURPLE=$(tput setab 5) BG_CYAN=$(tput setab 6) BG_WHITE=$(tput setab 7) #foreground colors FG_RED=$(tput setaf 1) FG_GREEN=$(tput setaf 2) FG_YELLOW=$(tput setaf 3) FG_BLUE=$(tput setaf 4) FG_PURPLE=$(tput setaf 5) FG_CYAN=$(tput setaf 6) FG_WHITE=$(tput setaf 7) #text-decoration FG_BOLD=$(tput bold) FG_HB=$(tput dim) FG_UN=$(tput smul) FG_REVERSE=$(tput rev) #back to defaults NORM=$(tput sgr0) fi #functions to display progress dots () { if [ "$interactive" != 'no' ]; then while true; do echo -n "."; sleep 0.5 done fi } estart(){ if [ "$interactive" != 'no' ]; then echo -n "$1" dots & dots_pid=$! fi } efinish(){ estatus=$? if [ "$interactive" != 'no' ]; then if [ "$estatus" -eq 0 ];then echo "[ ${FG_GREEN}OK${NORM} ]" else echo "[ ${FG_RED}FAIL${NORM} ]" fi kill $dots_pid wait $dots_pid 2>/dev/null fi } #detect server uptime server_uptime () { uptime=$(</proc/uptime) uptime=${uptime%%.*} s=$(( uptime%60 )) m=$(( uptime/60%60 )) h=$(( uptime/60/60%24 )) d=$(( uptime/60/60/24 )) uptime=$d'd '$h'h '$m'm '$s's ' curtime=$(date +'%Y-%m-%d %H:%M:%S') } #detect cifs mount mnt_detect () { MNT=$(mount -l | grep $mnt_dir) if [ ! -z "$MNT" ]; then MNT=$FG_GREEN$MNT$NORM else MNT=$FG_RED"error(not found)"$NORM fi }
#!/bin/sh SCRIPT_DIR=`dirname $0` source $SCRIPT_DIR/utils.sh clear echo "=========================================" echo " Mounted folder configuration" echo " (/var/www)" echo "=========================================" echo old_address=$(cat /root/file_server) old_username=$(grep 'username=' /root/.cifscreds | awk -F '=' '{ print $2 }') old_password=$(grep 'password=' /root/.cifscreds | awk -F '=' '{ print $2 }') echo "Type new value and press ENTER or just press ENTER to leave current value."; echo ; read -p "Address of fileserver, type like //ip/folder (current value $FG_YELLOW$old_address$NORM): " address ; read -p "Username (current value $FG_YELLOW$old_username$NORM): " username ; read -p "Password (current value $FG_YELLOW$old_password$NORM): " password ; if [ -z "$address" ]; then address=$old_address; fi if [ -z "$username" ]; then username=$old_username; fi if [ -z "$password" ]; then password=$old_password; fi echo "=======================================" echo " New parameters" echo "=======================================" echo -e "IP address of fileserver: "$address echo -e "Username: "$username echo -e "Password: "$password echo "=======================================" echo read -p "Save changes? (y/N) " key ; if [ $key == "Y" -o $key == "y" ]; then echo "username=$username password=$password" > /root/.cifscreds echo "$address" > /root/file_server estart "Unmounting..." umount /var/www efinish estart "Mounting..." /root/cifs_mount.sh efinish echo ; read -p "Done. Press any key" key ; else echo ; read -p "Nothing was changed. Press any key" key ; fi
Source: https://habr.com/ru/post/282884/
All Articles