-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.sh
93 lines (78 loc) · 2.54 KB
/
installer.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
#!/bin/bash
## install dependencies
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install git php php-fpm php-cgi php-xml php-curl php-gd php-sqlite3 composer fswebcam ftp -y
# install node + npm
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
# install yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
# clean
sudo apt-get autoremove -y
# apache2 settings
sudo bash -c 'cat > /etc/apache2/sites-available/timelapse.conf' << EOF
<VirtualHost *:80>
#ServerName timelapse.local
#ServerAlias timelapse.local
#ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/timelapse.error.log
#CustomLog ${APACHE_LOG_DIR}/timelapse.access.log combined
<Directory /var/www/html>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
<Directory /var/www/html/public/bundles>
FallbackResource disabled
</Directory>
</VirtualHost>
EOF
sudo systemctl enable apache2.service
sudo systemctl start apache2.service
## Deploy Symfony project
# save current html folder
sudo cp -r /var/www/html /var/www/html.save
# create symlink from project to http folder
sudo ln -s public /var/www/html
# fix ownership
sudo chown -R www-data:www-data /var/www/html
# edit .env.local with db name and path
sudo bash -c 'cat > .env.local' << EOF
APP_ENV=prod
APP_SECRET=mysecretisawesome
DATABASE_URL="sqlite:///%kernel.project_dir%/var/timelapse.db"
EOF
## deploy symfony project
# install project dependencies
composer install
# create database
php bin/console d:d:c
# force update db schema
php bin/console d:s:u --force
# clear symfony cache
php bin/console c:c
# fix mode on var
sudo chmod -R 777 var
# install front assest
yarn install
# build js and css
yarn encore production
# restart http server
sudo service apache2 restart
# set hostname
hostname="timelapse"
current_hostname=$(hostname)
if [ "$current_hostname" != "$hostname" ]
then
echo "Change the current device hostname: $current_hostname by: $hostname"
sudo hostname "$hostname"
sudo sed -i "s/$current_hostname/$hostname/g" /etc/hosts
sudo sed -i "s/$current_hostname/$hostname/g" /etc/hostname
echo "Device will reboot in 5sec..."
sleep 5
sudo reboot
fi