most work done on the install script
This commit is contained in:
parent
e51b376b43
commit
592e961e70
1 changed files with 80 additions and 12 deletions
|
@ -1,15 +1,83 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
get_distro(){
|
|
||||||
arch=$(uname -m)
|
USER=zammad
|
||||||
kernel=$(uname -r)
|
REPOURL=git@github.com:martini/zammad.git
|
||||||
if [ -f /etc/lsb-release ]; then
|
DBNAME=zammad
|
||||||
os=$(lsb_release -s -d)
|
DBUSER=zammad
|
||||||
elif [ -f /etc/debian_version ]; then
|
|
||||||
os="Debian $(cat /etc/debian_version)"
|
function check_requirements() {
|
||||||
elif [ -f /etc/redhat-release ]; then
|
items="git useradd sudo getent curl bash gcc make svn apg"
|
||||||
os=`cat /etc/redhat-release`
|
for item in $items
|
||||||
else
|
do
|
||||||
os="$(uname -s) $(uname -r)"
|
which $item > /dev/null
|
||||||
fi
|
if [ $? -ne 0 ]; then
|
||||||
|
echo Please install $item and start this script again.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_requirements
|
||||||
|
|
||||||
|
#
|
||||||
|
# @TODO Should the mysql user be created?
|
||||||
|
# @TODO Install Elasticsearch?
|
||||||
|
# @TODO Should the script create a VirtualHost or a config file to include for apache/nginx?
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for zammad user and create if needed
|
||||||
|
#
|
||||||
|
id -u "${USER}" > /dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
useradd -c 'user running zammad' -m -s /bin/bash $USER
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# find the user's homedir and primary group name
|
||||||
|
#
|
||||||
|
HOMEDIR=$(getent passwd $USER | cut -d: -f 6)
|
||||||
|
GROUP=$(id -gn $USER)
|
||||||
|
|
||||||
|
cd "${HOMEDIR}"
|
||||||
|
sudo -u "${USER}" -H git clone $REPOURL zammad
|
||||||
|
cd zammad
|
||||||
|
LATEST=$(git tag --list|sort|tail -1)
|
||||||
|
git checkout tags/"${LATEST}"
|
||||||
|
chown -R "${USER}":"${GROUP}" .
|
||||||
|
|
||||||
|
#
|
||||||
|
# RVM
|
||||||
|
#
|
||||||
|
sudo -u "${USER}" -H bash -c 'curl -sSL https://get.rvm.io | bash -s stable'
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# install Ruby
|
||||||
|
#
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'rvm install 2.1.2'
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'rvm alias create default 2.1.2'
|
||||||
|
|
||||||
|
#
|
||||||
|
# after rvm requirements
|
||||||
|
# Installing required packages: gawk, g++, libreadline6-dev, zlib1g-dev, libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, autoconf, libgdbm-dev, libncurses5-dev, automake, libtool, bison, pkg-config, libffi-dev................
|
||||||
|
|
||||||
|
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && gem install rails --no-ri --no-rdoc'
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && bundle install'
|
||||||
|
|
||||||
|
DBPASS=$(apg -x8|head -1)
|
||||||
|
echo Password $DBPASS
|
||||||
|
mysql -e "GRANT ALL ON ${DBNAME}.* to '${DBUSER}'@'localhost' IDENTIFIED BY '$DBPASS'";
|
||||||
|
sudo -u $USER -H cp ${HOMEDIR}/zammad/config/database.yml.dist ${HOMEDIR}/zammad/config/database.yml
|
||||||
|
sudo -u $USER -H sed -i s/some_pass/${DBPASS}/g ${HOMEDIR}/zammad/config/database.yml
|
||||||
|
sudo -u $USER -H sed -i s/some_user/${DBUSER}/g ${HOMEDIR}/zammad/config/database.yml
|
||||||
|
sudo -u $USER -H sed -i s/zammad_prod/zammad/g ${HOMEDIR}/zammad/config/database.yml
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && RAILS_ENV=production rake db:create'
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && RAILS_ENV=production rake db:migrate'
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && RAILS_ENV=production rake db:seed'
|
||||||
|
sudo -u "${USER}" -H bash -l -c 'cd ~/zammad && RAILS_ENV=production rake assets:precompile'
|
||||||
|
|
Loading…
Reference in a new issue