#!/bin/sh mount -t vboxsf $1 $2
#!/bin/sh # Author: Dmitry Vapelnik # Email: dvapelnik@gmail.com # - logfile='/var/log/vbox-sf.log' # , mountPrefix='/var/www/html/'; # - hn='.'`hostname` # , VirtualBox sharedFolders=`df | egrep "\/media\/sf_\$2[^ ]*" -o | sed -e 's/\/media\/sf_//'` #================ LOG ==========================================================# function log { echo [`date +"%F %T"`] $1 $2 >> $logfile } #================ MOUNTING =====================================================# function mountFn { echo "Mounting...."; for f in $sharedFolders; do mountPath=$mountPrefix$f$hn if cat /proc/mounts | grep vbox | grep $mountPath &> /dev/null; then echo Already mounted. Continue..; else rm -rf $mountPath 2> /dev/null; mkdir -p $mountPath; chown apache:apache $mountPath; if mount -t vboxsf $f $mountPath -o umask=0022,uid=apache,gid=apache; then echo Mounted $f log mounted $mountPath # # XDebug mkdir -p /var/www/html/$f$hn/xd_profile_$f$hn mkdir -p /var/www/html/$f$hn/xd_trace_$f$hn if [ -f $mountPath'/httpd.conf' ]; then # httpd cat $mountPath'/httpd.conf' | sed -e "s/<%domain%>/$f$hn/g" > /etc/httpd/conf/sf/$f$hn.conf if [ -f $mountPath'/aftermount.sh' ]; then # , # bash $mountPath'/aftermount.sh' $mountPath; fi fi fi fi done; # - service httpd restart } #================ UNMOUNTING ===================================================# function umountFn { echo "Unmounting..." # - service httpd stop for f in $sharedFolders; do mountPath=$mountPrefix$f$hn # - find $mountPath -type f -name httpd_"$f""$hn"_*.log -exec rm -f {} \; # rm -rf $mountPath/xd_profile_"$f""$hn" rm -rf $mountPath/xd_trace_"$f""$hn" # , # if [ -f $mountPath'/beforeumount.sh' ]; then bash $mountPath'/beforeumount.sh' $mountPath; fi # umount $mountPath # if [[ $? -eq 0 ]]; then rm -rf $mountPath 2> /dev/null rm -f /etc/httpd/conf/sf/$f$hn.conf 2> /dev/null echo "Unmounted and removed $f" log umounted $mountPath else echo "Not unmounted" fi done; # - service httpd start } #================ STATUS =======================================================# function statusFn { com=0 for f in $sharedFolders; do mountPath=$mountPrefix$f$hn if df | grep $mountPath &> /dev/null; then com=`expr $com + 1`; if [ $com -eq 1 ]; then echo List of mounted resources: fi df | grep $mountPath | egrep -o '\/.+$' fi done if [ $com -eq 0 ]; then echo No shared storage mounted fi } #===============================================================================# if [ "$1" == "mount" ]; then mountFn; exit 0 elif [ "$1" == "umount" ]; then umountFn; exit 0 elif [ "$1" == "status" ]; then statusFn; exit 0 else cat << EOF No arguments supplied ----------------------------------------------------------------------------- Usage: ----------------------------------------------------------------------------- Using with single argument one of: mount : for mounting all shared folders under /var/www/html directory umount : for unmounting all shared folders under /var/www/html directory status : for checking mount status ----------------------------------------------------------------------------- Using with two argument for mounting or unmounting single folder Example: vbox-sf mount foo : will mount shared folder /media/sf_foo into /var/www/html/foo.domain.com vbox-sf umount foo : will umount shared folder /media/sf_foo from /var/www/html/foo.domain.com EOF exit 1 fi exit 0
<VirtualHost *:80> DocumentRoot /var/www/html/<%domain%> ServerName <%domain%> ServerAlias www.<%domain%> DirectoryIndex index.php <Directory /var/www/html/<%domain%>> AllowOverride All php_admin_value open_basedir /var/www/html/<%domain%>:/tmp:/usr/share:/var/lib </Directory> CustomLog /var/www/html/<%domain%>/httpd_<%domain%>_access.log combined ErrorLog /var/www/html/<%domain%>/httpd_<%domain%>_error.log php_admin_value xdebug.profiler_output_dir /var/www/html/<%domain%>/xd_profile_<%domain%> php_admin_value xdebug.trace_output_dir /var/www/html/<%domain%>/xd_trace_<%domain%> </VirtualHost>
# mkdir -p /etc/httpd/conf/sf
in which configs of virtual hosts of the web server will be stored. At the same time, at the end of the /etc/httpd/conf/httpd.conf file, you need to include all configs that we will store in the above folder: include "conf/sf/*.conf"
# /path/to/vbox-sf.sh mount
# /path/to/vbox-sf.sh mount test
# /path/to/vbox-sf.sh umount test
#!/bin/bash # # Author: Dmitry Vapelnik # Email: dvapelnik@gmail.com ### BEGIN INIT INFO # Required-Start: httpd mysqld vboxadd-service vboxadd # Required-Stop: httpd mysqld vboxadd-service vboxadd # Default-Start: 3 # Default-Stop: 0 6 # Short-Description: Mounting VirtualBox shared folders # Description: This file should be used to mount and umount # VirtualBox shared folders ### END INIT INFO # Get function from functions library . /etc/init.d/functions prog="VBoxSF" lockfile='/var/lock/subsys/vboxsf' # Start the service vbox-sf start() { # initlog -c "echo -n Starting $prog server: " /root/bin/vbox-sf mount &> /dev/null && touch $lockfile success $"$prog: mounted" echo } # Restart the service vbox-sf stop() { # initlog -c "echo -n Umounting $prog: " /root/bin/vbox-sf umount &> /dev/null && rm -f $lockfile success $"$prog: umounted" echo } status() { /root/bin/vbox-sf status } ### main logic ### case "$1" in start) start ;; stop) stop ;; status) status ;; restart|reload|condrestart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit 0
# mkdir -p /root/bin # ln -s /root/scripts/vbox-sf.sh /root/bin/vbox-sf
# chkconfig --add vboxsf
# chkconfig | grep vboxsf
# service vboxsf start # service vboxsf stop # service vboxsf restart # service vboxsf status
#!/bin/sh # Author: Dmitry Vapelnik # Email: dvapelnik@gmail.com if [ $# -eq 0 ]; then echo 'No arguments supplied'; echo 'Exit'; exit 0; fi ###################################################### dbAdminUser='ourDbAdminLogin' dbAdminPass='ourDbAdminPassword' dbName='ourDbName' dbUser='ourDbUser' dbPass='ourDbPassword' dbHost='localhost' dbDump=$1'/db.sql' ###################################################### queryCreateUser="CREATE USER '$dbUser'@'$dbHost' IDENTIFIED BY '$dbPass'; CREATE DATABASE IF NOT EXISTS \`$dbName\`; GRANT ALL PRIVILEGES ON \`$dbName\`.* TO '$dbUser'@'$dbHost'; FLUSH PRIVILEGES;" echo Creating new user... if mysql -u$dbAdminUser -p$dbAdminPass -e "$queryCreateUser"; then echo User added echo Using MySQL dump if mysql -u$dbAdminUser -p$dbAdminPass $dbName < $dbDump; then echo MySQL dump loaded into $dbName else echo MySQL dump not loaded fi else echo Error: user not added exit fi
#!/bin/sh # Author: Dmitry Vapelnik # Email: dvapelnik@gmail.com if [ $# -eq 0 ]; then echo 'No arguments supplied'; echo 'Exit'; exit 0; fi ###################################################### dbAdminUser='dbAdminUser' dbAdminPass='dbAdminPass' dbName='ourDbName' dbUser='ourDbUser' dbHost='localhost' dbDump=$1'/db.sql' ###################################################### queryRemove="DROP DATABASE \`$dbName\`; DROP USER '$dbUser'@'$dbHost'; FLUSH PRIVILEGES;" echo Dumping MySQL DB into file.. if mysqldump -u$dbAdminUser -p$dbAdminPass $dbName > $dbDump; then echo DB dumped into file echo Removing user and database if mysql -u$dbAdminUser -p$dbAdminPass -e "$queryRemove"; then echo User and DB was removed else echo Error on removing fi fi
$ cat /etc/dnsmasq.conf | egrep -v "(^#.*|^$)" listen-address=127.0.0.1 address=/natty.nat/192.168.191.160 address=/ketty.nat/192.168.191.161 address=/betsy.nat/192.168.191.162
; - XDebug zend_extension="xdebug.so" xdebug.cli_color=1 xdebug.remote_enable=true xdebug.remote_host="192.168.191.1" xdebug.remote_port=9000 xdebug.remote_handler="dbgp" xdebug.remote_connect_back=1 ; Profiler xdebug.profiler_enable = 0 xdebug.profiler_enable_trigger = 1 xdebug.profiler_append = 0 ; Trace options xdebug.collect_includes = 1 xdebug.collect_params = 4 xdebug.collect_vars = 0 xdebug.dump.REQUEST = * xdebug.dump.SESSION = * ;xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD xdebug.dump.SERVER = * xdebug.dump_globals = 1 xdebug.dump_once = 1 xdebug.dump_undefined = 0 xdebug.show_mem_delta = Off ;xdebug.file_link_format = '' xdebug.manual_url = http://www.php.net xdebug.show_exception_trace = 1 xdebug.show_local_vars = 1 xdebug.show_mem_delta = 1 ; Traces xdebug.auto_trace = 0 xdebug.collect_assignments = 1 xdebug.collect_return = 1 xdebug.trace_enable_trigger = 1 ; 0 for parsing ; 1 human readable xdebug.trace_format = 1 xdebug.trace_options = 0 xdebug.trace_output_name = trace.%c
Source: https://habr.com/ru/post/236573/
All Articles