Create install_orbit_environment.sh.(Automatic install all environment for ubuntu)
This commit is contained in:
parent
f46eddd73d
commit
a61784b116
10
README.md
10
README.md
|
@ -1,4 +1,4 @@
|
||||||
# Ubuntu 18.04 LTS 安裝 R4.5 標準流程
|
# Ubuntu 安裝 R4.5 標準流程
|
||||||
## 前置作業
|
## 前置作業
|
||||||
* Ubuntu 18.04 LTS 已安裝完畢並能遠端連線進入
|
* Ubuntu 18.04 LTS 已安裝完畢並能遠端連線進入
|
||||||
* 當前帳號可以使用 sudo 指令
|
* 當前帳號可以使用 sudo 指令
|
||||||
|
@ -15,6 +15,14 @@ $ sudo ls -la /root # 測試 rulingcom sudo 是否可用
|
||||||
$ exit; exit # 第一次 exit 退回 root 帳號,第二次 exit 退回剛登入的帳號
|
$ exit; exit # 第一次 exit 退回 root 帳號,第二次 exit 退回剛登入的帳號
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 下載裝機script並執行(除了網站的部分需手動,其餘皆已改為自動,其他內容不用再執行)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/install_orbit_environment.sh
|
||||||
|
$ bash install_orbit_environment.sh #請使用要執行網站的user(須為具有sudo權限之帳號)來執行,執行後會需要輸入user密碼
|
||||||
|
## 以下其他內容均不需執行,可直接進行架站或移機
|
||||||
|
```
|
||||||
|
|
||||||
## 安裝libgmp(Ubuntu 14.04需要)
|
## 安裝libgmp(Ubuntu 14.04需要)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
#!/bin/bash
|
||||||
|
ubuntu_version=$(lsb_release -rs)
|
||||||
|
sudo apt update
|
||||||
|
if [[ $ubuntu_version =~ '14' ]]; then
|
||||||
|
sudo apt install libgmp-dev
|
||||||
|
fi
|
||||||
|
echo "postfix postfix/mailname string $USER" | sudo debconf-set-selections
|
||||||
|
echo "postfix postfix/main_mailer_type string 'Local only'" | sudo debconf-set-selections
|
||||||
|
sudo apt-get install -y postfix
|
||||||
|
sudo service postfix start
|
||||||
|
sudo apt install nginx -y
|
||||||
|
sudo service nginx restart
|
||||||
|
cd /etc/nginx/
|
||||||
|
sudo mkdir orbit_sites/
|
||||||
|
sudo vim nginx.conf
|
||||||
|
sudo sed -i 's/\(include\ \/etc\/nginx\/sites-enabled\/\*\;\)/\1\n\tinclude\ \/etc\/nginx\/sites-enabled\/\*\;\n\tinclude\ \/etc\/nginx\/orbit_sites\/*;/g' nginx.conf
|
||||||
|
if [[ $ubuntu_version =~ '20' ]] || [[ $ubuntu_version =~ '21' ]]; then
|
||||||
|
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb
|
||||||
|
sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5.6_amd64.deb
|
||||||
|
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
||||||
|
sudo apt-get install gnupg -y
|
||||||
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y mongodb-org=5.0.6 mongodb-org-database=5.0.6 mongodb-org-server=5.0.6 mongodb-org-shell=5.0.6 mongodb-org-mongos=5.0.6 mongodb-org-tools=5.0.6
|
||||||
|
sudo service mongod restart
|
||||||
|
fi
|
||||||
|
sudo bash -l -c "cd /root; \
|
||||||
|
apt-get install libjpeg62 -y; \
|
||||||
|
wget http://download.sourceforge.net/libpng/libpng-1.5.13.tar.gz; \
|
||||||
|
tar xvfz libpng-1.5.13.tar.gz; \
|
||||||
|
cd libpng-1.5.13/; \
|
||||||
|
./configure; \
|
||||||
|
make && sudo make install; \
|
||||||
|
apt install -y libltdl-dev graphviz libpng-dev libfftw3-dev; \
|
||||||
|
apt-get install -y libjpeg-turbo8-dev; \
|
||||||
|
apt install -y libgif-dev libjpeg-dev libopenexr-dev libpng-dev libwebp-dev; \
|
||||||
|
apt install -y cmake pkg-config libbrotli-dev; \
|
||||||
|
wget http://www.imagemagick.org/download/ImageMagick.tar.gz; \
|
||||||
|
tar xvfz ImageMagick.tar.gz; \
|
||||||
|
cd $(ls -d ImageMagick-7*); \
|
||||||
|
./configure --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes --disable-shared --with-modules; \
|
||||||
|
make && make install; \
|
||||||
|
ln -s /usr/local/lib/* /usr/lib/.; \
|
||||||
|
ln -s /usr/local/lib/pkgconfig/* /usr/lib/pkgconfig/.; \
|
||||||
|
ln -s /usr/local/bin/* /usr/bin/.; \
|
||||||
|
convert -list configure;"
|
||||||
|
sudo apt-get install software-properties-common -y
|
||||||
|
sudo apt-add-repository -y ppa:rael-gc/rvm
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install rvm -y
|
||||||
|
sudo usermod -a -G rvm $USER
|
||||||
|
echo 'source "/etc/profile.d/rvm.sh"' >> ~/.bashrc
|
||||||
|
source "/etc/profile.d/rvm.sh"
|
||||||
|
sudo chown $USER:$USER $HOME -R
|
||||||
|
rvm user gemsets
|
||||||
|
rvm install 2.1.10
|
||||||
|
rvm --default use 2.1.10
|
||||||
|
if [[ $ubuntu_version =~ '20' ]] || [[ $ubuntu_version =~ '21' ]]; then
|
||||||
|
gem install nokogiri -v 1.7.0.1
|
||||||
|
fi
|
||||||
|
sudo apt-get install screen
|
||||||
|
sudo vim /etc/rsyslog.d/50-default.conf
|
||||||
|
sudo sed -i 's/#cron\.\*/cron\.\*/g' /etc/rsyslog.d/50-default.conf
|
||||||
|
sudo service rsyslog restart
|
||||||
|
sudo mkdir /home/backup/db/ -p
|
||||||
|
sudo mkdir /home/backup/orbit/ -p
|
||||||
|
sudo apt-get install rsnapshot -y
|
||||||
|
sudo sed -i 's/^[^#]etain/#retain/g' /etc/rsnapshot.conf
|
||||||
|
sudo sed -i 's/\(retain\tdelta\t3\)/\1\nretain\tdaily\t7/g' /etc/rsnapshot.conf
|
||||||
|
sudo sed -i 's/snapshot_root.*/snapshot_root\t\/home\/backup\/orbit/g' /etc/rsnapshot.conf
|
||||||
|
sudo sed -i 's/^\(backup\t.*\)/#\1/g' /etc/rsnapshot.conf
|
||||||
|
matched_backup_home=$(grep -P "backup\t$HOME" /etc/rsnapshot.conf|xargs)
|
||||||
|
if [ -z $matched_backup_home ]; then
|
||||||
|
sudo sed -i "$(echo "s/^\(#backup\t\/home\/\t\)/backup\t$(echo $HOME|sed 's/\//\\\//g')\tlocalhost\/\n\1/g")" /etc/rsnapshot.conf
|
||||||
|
fi
|
||||||
|
sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/orbit_logrotate -O /etc/logrotate.d/orbit
|
||||||
|
sudo sed -i "s/rulingcom/$USER/g" /etc/logrotate.d/orbit
|
||||||
|
sudo logrotate -d /etc/logrotate.conf
|
||||||
|
sudo /usr/sbin/logrotate -f /etc/logrotate.conf
|
||||||
|
sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/orbit_service.sh -O /etc/init.d/orbit
|
||||||
|
sudo sed -i "s/ORBIT_USER=.*/ORBIT_USER=$USER/g" /etc/init.d/orbit
|
||||||
|
sudo chmod 755 /etc/init.d/orbit
|
||||||
|
sudo update-rc.d orbit defaults
|
||||||
|
sudo systemctl enable mongod.service
|
||||||
|
sudo_crontab_jobs=$(sudo crontab -l)
|
||||||
|
if [[ $sudo_crontab_jobs =~ "@reboot /bin/bash -l -c" ]]; then
|
||||||
|
echo "Already exist reboot crontab!"
|
||||||
|
else
|
||||||
|
echo "Adding reboot crontab!"
|
||||||
|
echo $sudo_crontab_jobs$'\n''@reboot /bin/bash -l -c "rm -f /tmp/mongodb-27017.sock && chown mongodb:mongodb /var/lib/mongodb/ -R && chown mongodb:mongodb /var/log/mongodb -R && /usr/sbin/service mongod restart && /etc/init.d/orbit restart"'| sudo crontab -
|
||||||
|
fi
|
||||||
|
sudo_crontab_jobs=$(sudo crontab -l)
|
||||||
|
if [[ $sudo_crontab_jobs =~ "mongodump -o /" ]]; then
|
||||||
|
echo "Already exist mongodump crontab!"
|
||||||
|
else
|
||||||
|
echo "Adding mongodump crontab!"
|
||||||
|
echo $sudo_crontab_jobs$'\n''0 3 * * * mongodump -o /home/backup/db/`date "+\%Y\%m\%d"`_db'| sudo crontab -
|
||||||
|
fi
|
||||||
|
sudo_crontab_jobs=$(sudo crontab -l)
|
||||||
|
if [[ `echo $sudo_crontab_jobs | grep -P "rm -fr.*/db/"` ]]; then
|
||||||
|
echo "Already exist remove old mongo backup crontab!"
|
||||||
|
else
|
||||||
|
echo "Adding remove old mongo backup crontab!"
|
||||||
|
echo $sudo_crontab_jobs$'\n''0 4 * * * rm -fr /home/backup/db/`date --date="1 week ago" "+\%Y\%m\%d"`_db'| sudo crontab -
|
||||||
|
fi
|
||||||
|
sudo_crontab_jobs=$(sudo crontab -l)
|
||||||
|
if [[ $sudo_crontab_jobs =~ "/usr/bin/rsnapshot" ]]; then
|
||||||
|
echo "Already exist rsnapshot crontab!"
|
||||||
|
else
|
||||||
|
echo "Adding rsnapshot crontab!"
|
||||||
|
echo $sudo_crontab_jobs$'\n''15 4 * * * /usr/bin/rsnapshot daily'| sudo crontab -
|
||||||
|
fi
|
||||||
|
echo "Finish setting orbit environment!"
|
||||||
|
echo "Please install orbit web app and setting nginx for single web by yourself!"
|
|
@ -0,0 +1,36 @@
|
||||||
|
/home/rulingcom/*/*/log/*.log {
|
||||||
|
daily
|
||||||
|
rotate 7
|
||||||
|
compress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
copytruncate
|
||||||
|
postrotate
|
||||||
|
[ ! -f /run/nginx.pid ] || kill -USR1 `cat /run/nginx.pid`
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
/home/rulingcom/*/*/*/log/*.log {
|
||||||
|
daily
|
||||||
|
rotate 7
|
||||||
|
compress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
copytruncate
|
||||||
|
postrotate
|
||||||
|
[ ! -f /run/nginx.pid ] || kill -USR1 `cat /run/nginx.pid`
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/var/log/mongodb/*.log {
|
||||||
|
daily
|
||||||
|
rotate 7
|
||||||
|
compress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
copytruncate
|
||||||
|
postrotate
|
||||||
|
[ ! -f /var/lib/mongodb/mongod.lock ] || kill -USR1 `cat /var/lib/mongodb/mongod.lock`
|
||||||
|
endscript
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
# upstream xxx_sock {
|
||||||
|
upstream orbit_sock {
|
||||||
|
# server unix:/path/to/your/r45/tmp/unicorn.sock;
|
||||||
|
server unix:/home/rulingcom/orbit_sites/orbit/tmp/unicorn.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
# root /path/to/your/r45/public;
|
||||||
|
root /home/rulingcom/orbit_sites/orbit/public;
|
||||||
|
|
||||||
|
# server_name your.website.address;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
client_max_body_size 500m;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html $uri.html @app;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @app {
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_connect_timeout 360;
|
||||||
|
# proxy_pass http://xxx_sock;
|
||||||
|
proxy_pass http://orbit_sock;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,229 @@
|
||||||
|
#!/bin/bash
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: ruling.digital
|
||||||
|
# Required-Start: $network
|
||||||
|
# Required-Stop:
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: Start orbit daemon at boot time
|
||||||
|
# Description: Start orbit daemon at boot time
|
||||||
|
### END INIT INFO
|
||||||
|
ORBIT_USER=rulingcom
|
||||||
|
|
||||||
|
if [ -f "/home/$ORBIT_USER/.rvm/scripts/rvm" ]; then
|
||||||
|
source /home/$ORBIT_USER/.rvm/scripts/rvm
|
||||||
|
rvm use default
|
||||||
|
else
|
||||||
|
if [ -f "/etc/profile.d/rvm.sh" ]; then
|
||||||
|
source /etc/profile.d/rvm.sh
|
||||||
|
elif [ "$1" != "setup" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "Orbit server dependencies is missing. Please run setup first."
|
||||||
|
echo "command: service orbit setup"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
ORBIT_SITES=`pwd`
|
||||||
|
ORBIT_GIT=http://gitlab.tp.rulingcom.com/saurabh/orbit4-5.git
|
||||||
|
NGINX_ORBIT_SITES=/etc/nginx/orbit_sites
|
||||||
|
|
||||||
|
RAILS_ENV=production
|
||||||
|
|
||||||
|
sig () {
|
||||||
|
test -s "$ORBIT_ROOT/tmp/pids/unicorn.pid" && kill -$1 `cat $ORBIT_ROOT/tmp/pids/unicorn.pid`
|
||||||
|
}
|
||||||
|
|
||||||
|
get_orbit_root () {
|
||||||
|
if [ ! -f $NGINX_ORBIT_SITES/$1 ]; then echo "Site $1 not found" && exit 0; fi
|
||||||
|
ORBIT_ROOT=`cat $NGINX_ORBIT_SITES/$1 | grep 'root' | grep -v '#' | xargs | awk '{print $2}'`;
|
||||||
|
ORBIT_ROOT=${ORBIT_ROOT//"/public;"/""};
|
||||||
|
if [ ! -d $ORBIT_ROOT ]; then echo "Site folder $ORBIT_ROOT not fount"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_orbit () {
|
||||||
|
sig 0 $ORBIT_ROOT && echo >&2 "$ORBIT_ROOT Already running";
|
||||||
|
echo "Starting $ORBIT_ROOT";
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_ROOT && bundle exec unicorn_rails -D -E $RAILS_ENV -c config/unicorn.rb";
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
get_orbit_root $2
|
||||||
|
start_orbit
|
||||||
|
else
|
||||||
|
for APP in `ls -1 $NGINX_ORBIT_SITES`; do
|
||||||
|
get_orbit_root $APP;
|
||||||
|
start_orbit;
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
while [ `whoami` != "root" ]; do
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
read -p "Stop Orbit $2? (y/n) " CONFIRM
|
||||||
|
else
|
||||||
|
read -p "Stop All Orbits? (y/n) " CONFIRM
|
||||||
|
fi
|
||||||
|
case "$CONFIRM" in
|
||||||
|
y|Y ) break;;
|
||||||
|
n|N ) exit 0;;
|
||||||
|
* ) echo "(y/n)";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
get_orbit_root $2
|
||||||
|
echo "Stopping $ORBIT_ROOT"
|
||||||
|
sig QUIT
|
||||||
|
else
|
||||||
|
for APP in `ls -1 $NGINX_ORBIT_SITES`; do
|
||||||
|
get_orbit_root $APP;
|
||||||
|
echo "Stopping $ORBIT_ROOT";
|
||||||
|
sig QUIT && continue;
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
force-stop)
|
||||||
|
while true; do
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
read -p "Stop Orbit $2? (y/n) " CONFIRM
|
||||||
|
else
|
||||||
|
read -p "Stop All Orbits? (y/n) " CONFIRM
|
||||||
|
fi
|
||||||
|
case "$CONFIRM" in
|
||||||
|
y|Y ) break;;
|
||||||
|
n|N ) exit 0;;
|
||||||
|
* ) echo "(y/n)";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
get_orbit_root $2
|
||||||
|
echo "Stopping $ORBIT_ROOT"
|
||||||
|
sig TERM
|
||||||
|
else
|
||||||
|
for APP in `ls -1 $NGINX_ORBIT_SITES`; do
|
||||||
|
get_orbit_root $APP;
|
||||||
|
echo "Stopping $ORBIT_ROOT";
|
||||||
|
sig TERM && continue;
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
restart|reload)
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
get_orbit_root $2
|
||||||
|
sig USR2 && echo "$ORBIT_ROOT reloaded OK" && exit 0
|
||||||
|
echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead"
|
||||||
|
start_orbit
|
||||||
|
else
|
||||||
|
for APP in `ls -1 $NGINX_ORBIT_SITES`; do
|
||||||
|
get_orbit_root $APP;
|
||||||
|
sig USR2 && echo "$ORBIT_ROOT reloaded OK" && continue;
|
||||||
|
echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead";
|
||||||
|
start_orbit;
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
create)
|
||||||
|
if [ "$0" == "/etc/init.d/orbit" ]; then
|
||||||
|
echo "Don't use service to create."
|
||||||
|
echo "Use: orbit create $2"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
test -s "$NGINX_ORBIT_SITES/$2" && echo "Site $2 already exist." && exit 0
|
||||||
|
test -s "$ORBIT_SITES/$2" && echo "File $ORBIT_SITES/$2 already exist." && exit 0
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "nginx server name: " SERVER_NAME
|
||||||
|
if [ ! -z "$SERVER_NAME" ]; then break; fi
|
||||||
|
done
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "port number: " PORT
|
||||||
|
if [ ! -z "$PORT" ]; then break; fi
|
||||||
|
done
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "database name: " DATABASE
|
||||||
|
if [ ! -z "$DATABASE" ]; then break; fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "Path: $ORBIT_SITES/$2"
|
||||||
|
echo "Database: $DATABASE"
|
||||||
|
echo http://$SERVER_NAME:$PORT
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Create Orbit $2? (y/n) " CONFIRM
|
||||||
|
case "$CONFIRM" in
|
||||||
|
y|Y ) break;;
|
||||||
|
n|N ) exit 0;;
|
||||||
|
* ) echo "(y/n)";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
sudo wget http://installer.tp.rulingcom.com/nginx4-5.conf
|
||||||
|
sudo cp nginx4-5.conf $NGINX_ORBIT_SITES/$2
|
||||||
|
sudo rm nginx4-5.conf
|
||||||
|
sudo perl -pi -e "s/{{ORBIT}}/$2/g" $NGINX_ORBIT_SITES/$2
|
||||||
|
sudo perl -pi -e "s#{{ORBIT_SITES}}#${ORBIT_SITES}#g" $NGINX_ORBIT_SITES/$2
|
||||||
|
sudo perl -pi -e "s/{{PORT}}/$PORT/g" $NGINX_ORBIT_SITES/$2
|
||||||
|
sudo perl -pi -e "s/{{SERVER_NAME}}/$SERVER_NAME/g" $NGINX_ORBIT_SITES/$2
|
||||||
|
sudo service nginx reload
|
||||||
|
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_SITES && git clone $ORBIT_GIT $2 && cd $2 && bundle"
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_SITES/$2 && perl -pi -e \"s/orbit_4_5/$DATABASE/g\" config/mongoid.yml"
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_SITES/$2 && bundle exec rake assets:precompile RAILS_ENV=production"
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_SITES/$2 && bundle exec unicorn_rails -D -E $RAILS_ENV -c $ORBIT_SITES/$2/config/unicorn.rb"
|
||||||
|
sudo su -l $ORBIT_USER -c "cd $ORBIT_SITES/$2 && bundle exec rake orbit_cron:install"
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "$2 is ready"
|
||||||
|
echo "Path: $ORBIT_SITES/$2"
|
||||||
|
echo http://`ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`:$PORT
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
setup)
|
||||||
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
|
||||||
|
sudo echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y upgrade
|
||||||
|
sudo apt-get install -y nginx git-core mongodb-org imagemagick curl openssh-server nano
|
||||||
|
|
||||||
|
sudo mkdir $NGINX_ORBIT_SITES
|
||||||
|
sudo perl -pi -e "s/sites-enabled/orbit_sites/g" /etc/nginx/nginx.conf
|
||||||
|
sudo rm -r /etc/nginx/sites-*
|
||||||
|
|
||||||
|
sudo apt-get --no-install-recommends --yes install gawk g++ gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev
|
||||||
|
|
||||||
|
sudo su -l $ORBIT_USER -c "\curl -sSL https://get.rvm.io | bash -s stable"
|
||||||
|
sudo su -l $ORBIT_USER -c "rvm install 2.1 --default"
|
||||||
|
echo "gem: --no-ri --no-rdoc" > /home/$ORBIT_USER/.gemrc
|
||||||
|
source /home/$ORBIT_USER/.rvm/scripts/rvm
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo "System is ready. You can start creating Orbit servers."
|
||||||
|
echo "command: orbit create Orbit_Folder_Name"
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "Usage $0 <start|stop|restart|force-stop|create|setup>"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue