-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·115 lines (94 loc) · 2.96 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
cd /install
if [[ -f checkpoint0 ]]
then
echo "skipping..."
else
# Check if root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# Make install folders
mkdir /install
cd /install
# Upgrade System
apt update -qq
apt upgrade -qq -y
# Install necessary packages
apt install software-properties-common nginx git dirmngr gnupg nodejs libncurses5-dev libgmp-dev libssl-dev -qq -y
# Get PGP Keys and install more software (See https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/focal.html)
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
apt-get install -y apt-transport-https ca-certificates
# Create dedicated user
adduser new-tool --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
# Add repository for Ruby Version Manager and Passenger(see https://github.com/rvm/ubuntu_rvm)
apt-add-repository -y ppa:rael-gc/rvm
sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger focal main > /etc/apt/sources.list.d/passenger.list'
apt update
apt install rvm libnginx-mod-http-passenger -y --quiet
# Add user to rvm group
usermod -a -G rvm new-tool
usermod -aG rvm $SUDO_USER
# Change to install directory and download latest version
cd /var/www/
git clone https://github.com/edbingo/new-tool
# Give user permission to R/W install folder
chown new-tool:new-tool -R new-tool/
chown $SUDO_USER:$SUDO_USER -R /install
# Required steps for passenger
if [ ! -f /etc/nginx/modules-enabled/50-mod-http-passenger.conf ]
then
ln -s /usr/share/nginx/modules-available/mod-http-passenger.load /etc/nginx/modules-enabled/50-mod-http-passenger.conf ;
fi
# Download config for nginx, and remove default settings
ls /etc/nginx/conf.d/mod-http-passenger.conf
cd /etc/nginx/sites-enabled/
rm default
wget https://raw.githubusercontent.com/edbingo/install/main/athene.bks-campus.ch
cp athene.bks-campus.ch /etc/nginx/sites-available/
systemctl restart nginx
# Set checkpoint and reboot
cd /install
touch checkpoint0
reboot
exit
fi
# Check that not root
if [ "$EUID" -ne 0 ]
then
echo "proceeding..."
else
echo "Root is no longer needed"
exit
fi
# Change to install directory
cd /install
if [[ -f checkpoint1 ]]
then
echo "Please Wait"
else
# Install ruby-2.6.0 system wide and set as default ruby
source /usr/share/rvm/scripts/rvm
cd /install
rvm install ruby-2.6.0
rvm use --default ruby-2.6.0
touch checkpoint1
echo "Please run this script again as newly created user new-tool (sudo su new-tool)"
exit
fi
cd /install
if [ "$EUID" -ne 1001 ]
then
echo "Please run as user new-tool (sudo su new-tool)"
exit
else
# Initiates databases and precompiles assets for new-tool
source /usr/share/rvm/scripts/rvm
rvm install ruby-2.6.0
cd /var/www/new-tool
git pull
bundle install --deployment --without development test
bundle exec rake assets:precompile db:migrate db:seed RAILS_ENV=production
echo "Install complete!"
fi