.sh脚本辅助 [英] .sh script assistance
本文介绍了.sh脚本辅助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找可以帮助我使用.sh脚本的人。
请参阅下面的脚本:
评论部分是在未注释的情况下需要帮助的地方,它将其下方的任何内容设置为字符串
如果在主脚本转储中发现任何其他问题,请执行我知道:)
问题
Hi,
I am looking for someone that can assist me with my .sh script.
Please see script below:
The commented section is where help is required when un-commented it sets anything below it as a "string"
If any other issues are noticed in main script dump please do let me know :)
ISSUE
# 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
FULL SCRIPT
FULL SCRIPT
#!/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
我尝试过:
What I have tried:
# 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
推荐答案
(cat<<< EOF
#< VirtualHost *:80>
#DocumentRoot/ var / www / html /
(cat <<EOF # <VirtualHost *:80> # DocumentRoot "/var/www/html/
{PROJECTFOLDER} / public
#<目录/ var / www / html /
{PROJECTFOLDER}/public" # <Directory "/var/www/html/
{PROJECTFOLDER} / public>
#AllowOverride所有
#要求所有授予
#< /目录>
#< / VirtualHost>
#EOF
#)
#echo
{PROJECTFOLDER}/public"> # AllowOverride All # Require all granted # </Directory> # </VirtualHost> # EOF # ) # echo "
这篇关于.sh脚本辅助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文