forked from ngocquyhoang/laravel-deploy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
44 lines (37 loc) · 1.18 KB
/
entrypoint.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
#!/bin/bash
mkdir -p /root/.ssh
ssh-keyscan -H "$2" >> /root/.ssh/known_hosts
if [ -z "$DEPLOY_KEY" ];
then
echo $'\n' "------ DEPLOY KEY NOT SET YET! ----------------" $'\n'
exit 1
else
printf '%b\n' "$DEPLOY_KEY" > /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
echo $'\n' "------ CONFIG SUCCESSFUL! ---------------------" $'\n'
fi
rsync --progress -avzh \
--exclude='.git/' \
--exclude='.git*' \
--exclude='.editorconfig' \
--exclude='.styleci.yml' \
--exclude='.idea/' \
--exclude='Dockerfile' \
--exclude='readme.md' \
--exclude='README.md' \
-e "ssh -i /root/.ssh/id_rsa" \
--rsync-path="sudo rsync" . $1@$2:$3
if [ $? -eq 0 ]
then
echo $'\n' "------ SYNC SUCCESSFUL! -----------------------" $'\n'
echo $'\n' "------ RELOADING PERMISSION -------------------" $'\n'
ssh -i /root/.ssh/id_rsa -t $1@$2 "sudo chown -R $4:$4 $3"
ssh -i /root/.ssh/id_rsa -t $1@$2 "sudo chmod 775 -R $3/web"
ssh -i /root/.ssh/id_rsa -t $1@$2 "sudo chmod 777 -R $3/runtime"
ssh -i /root/.ssh/id_rsa -t $1@$2 "sudo chmod 777 -R $3/web/assets"
echo $'\n' "------ CONGRATS! DEPLOY SUCCESSFUL!!! ---------" $'\n'
exit 0
else
echo $'\n' "------ DEPLOY FAILED! -------------------------" $'\n'
exit 1
fi