.ш оказание помощи скрипта
Привет,
Я ищу кого-то, кто может помочь мне с моим сценарием .sh.
Пожалуйста смотрите сценарий ниже:
Комментируемый раздел-это то место, где требуется помощь, когда без комментариев он устанавливает все, что находится ниже него, как "строку"
Если какие - либо другие проблемы будут замечены в основном дампе скрипта, пожалуйста, дайте мне знать :)
ВОПРОС
# setup hosts file # VHOST=$(cat <<EOF # <VirtualHost *:80> # DocumentRoot "/var/www/html/${PROJECTFOLDER}/public" # <Directory "/var/www/html/${PROJECTFOLDER}/public"> # AllowOverride All # Require all granted # </Directory> # </VirtualHost> # EOF # ) # echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf
ПОЛНЫЙ СЦЕНАРИЙ
#!/usr/bin/env bash # VOID installer for Debian, Ubuntu and CentOS # Use single quotes instead of double quotes to make it work with special-character passwords # PASSWORD='' # Detect Debian users running the script with "sh" instead of bash if readlink /proc/$$/exe | grep -qs "dash"; then echo "This script needs to be run with bash, not sh" exit 1 fi if [[ "$EUID" -ne 0 ]]; then echo "Sorry, you need to run this as root" exit 2 fi if grep -qs "CentOS release 5" "/etc/redhat-release"; then echo "CentOS 5 is too old and not supported" exit 3 fi if [[ -e /etc/debian_version ]]; then OS=debian GROUPNAME=nogroup RCLOCAL='/etc/rc.local' elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then OS=centos GROUPNAME=nobody RCLOCAL='/etc/rc.d/rc.local' else echo "Looks like you aren't running this installer on Debian, Ubuntu or CentOS" exit 4 fi echo "" echo "Please, use one word only, no special characters" read -p "Project folder name: " -e -i projectfolder PROJECTFOLDER echo "" if [[ -e /var/www/html/${PROJECTFOLDER} ]]; then while : do clear echo "Looks like ${PROJECTFOLDER} is already installed" echo "" echo "What do you want to do?" echo " 1) Exit" read -p "Select an option [1]: " option case $option in 1) exit;; esac done else clear echo "Welcome to this quick ${PROJECTFOLDER} installer" echo "" # VOID setup echo "I need to ask you a few questions before starting the setup" echo "You can leave the default options and just press enter if you are ok with them" echo "" echo "Please, use one word only, no special characters" read -p "Project folder name: " -e -i projectfolder PROJECTFOLDER echo "" echo "Please, use one word only, no special characters" read -p "GitHub username: " -e -i username USERNAME echo "" echo "Please, use one word only, no special characters" read -p "Repository name: " -e -i repository REPOSITORY echo "" echo "Okay, that was all I needed. We are ready to setup your ${PROJECTFOLDER} server now" read -n1 -r -p "Press any key to continue..." if [[ "$OS" = 'debian' ]]; then sudo apt-get update sudo apt-get -y upgrade sudo apt-get install -y apache2 sudo apt-get install -y php5 # install mysql sudo apt-get -y install mysql-server sudo apt-get install php5-mysql # install phpmyadmin sudo apt-get -y install phpmyadmin # install curl (needed to use git afaik) sudo apt-get -y install curl sudo apt-get -y install php5-curl # install openssl (needed to clone from GitHub, as github is https only) sudo apt-get -y install openssl # install PHP GD, the graphic lib (we create captchas and avatars) sudo apt-get -y install php5-gd # install git sudo apt-get -y install git else # Else, the distro is CentOS sudo yum -y update # Install apache webserver sudo yum -y install httpd # Install php sudo yum -y install php # Install mysql/mariadb # sudo yum -y install mariadb sudo yum -y install php-mysql # Install phpmyadmin sudo yum -y install phpmyadmin # Install curl sudo yum -y install curl sudo yum -y install php-curl # Install openssl sudo yum -y install openssl # Install graphical library for PHP sudo yum -y install php-gd # Install git sudo yum -y install git fi # Create project folder, written in 3 single mkdir-statements to make sure this runs everywhere without problems sudo mkdir "/var/www" sudo mkdir "/var/www/html" sudo mkdir "/var/www/html/${PROJECTFOLDER}" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $PASSWORD" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $PASSWORD" sudo debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" # setup hosts file # VHOST=$(cat <<EOF # <VirtualHost *:80> # DocumentRoot "/var/www/html/${PROJECTFOLDER}/public" # <Directory "/var/www/html/${PROJECTFOLDER}/public"> # AllowOverride All # Require all granted # </Directory> # </VirtualHost> # EOF # ) # echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf # enable mod_rewrite sudo a2enmod rewrite # restart apache if [[ "$OS" = 'debian' ]]; then # Little hack to check for systemd if pgrep systemd-journal; then systemctl restart apache2@server.service else /etc/init.d/apache2 restart fi else if pgrep systemd-journal; then systemctl restart apache2@server.service systemctl enable apache2@server.service else service apache2 restart chkconfig apache2 on fi fi # git clone VOID sudo git clone https://github.com/${USERNAME}/${REPOSITORY} "/var/www/html/${PROJECTFOLDER}" # install Composer curl -s https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer # go to project folder, load Composer packages cd "/var/www/html/${PROJECTFOLDER}" composer install # run SQL statements from install folder sudo mysql -h "localhost" -u "root" "-p${PASSWORD}" < "/var/www/html/${PROJECTFOLDER}/application/_installation/01-create-database.sql" sudo mysql -h "localhost" -u "root" "-p${PASSWORD}" < "/var/www/html/${PROJECTFOLDER}/application/_installation/02-create-table-users.sql" # writing rights to avatar folder sudo chown -R www-data "/var/www/html/${PROJECTFOLDER}/public/avatars" # if this didn't work for you, you can also try the hard way: #sudo chmod 0777 -R "/var/www/html/${PROJECTFOLDER}/public/avatars" # remove Apache's default demo file sudo rm "/var/www/html/index.html" echo "" echo "Installation complete!" echo "" echo "Your client configuration is available at" ~/"var/www/html/${PROJECTFOLDER}/application/config/config.production.php" fi
Что я уже пробовал:
# setup hosts file VHOST=$(cat <<EOF <VirtualHost *:80> DocumentRoot "/var/www/html/${PROJECTFOLDER}/public" <Directory "/var/www/html/${PROJECTFOLDER}/public"> AllowOverride All Require all granted </Directory> </VirtualHost> EOF ) echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf