This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fusig.sh
142 lines (128 loc) · 4.49 KB
/
fusig.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash --
#==============================================================================
#
# FILE: fusig.sh
#
# USAGE: fusig.sh [-u [branch] -B -f -c -e -h]
#
# DESCRIPTION: Updates Friendica installation.
# Copy script to suitable location and make it executable.
# Adjust the configurations below accordingly.
# Call script manually or automatically via a cron job.
# E.g. 00 04 * * * /usr/local/bin/fusig.sh
#
# REQUIREMENTS: git and working Friendica installation via github
#
#==============================================================================
#
# CONFIGURE SETTINGS
branch=develop # Set your branch, e.g. master or develop
FPATH=/var/www/friendica # Set path to your Friendica installation. Ensure no trailing slash.
CUSER=www-data # Set user that has permissions for the folder called "vendor".
FLOG=/var/www/friendica/logs/friendica.log
LOCKFILE=/tmp/fusig.lock # Alter this if you don't have permission for "/tmp".
# END OF CONFIGURATION
#==============================================================================
if [[ $1 = "-h" || $1 = "--help" ]]; then #help
echo "Usage: fusig.sh [argument]"
echo "Options:"
echo
echo " -u [branch] override branch setting"
echo
echo " -B update database structure"
echo " -f display Friendica versions"
echo " -c display script configuration"
echo " -e configure script"
echo " -h display this help and exit"
echo
echo "Examples: 'fusig.sh ' or 'fusig.sh -u master"
exit 0
fi
if [[ $1 = "-c" ]]; then # display configure
echo "Script configurations"
echo
echo " Branch: $branch"
echo " Friendica path: $FPATH"
echo " Composer user: $CUSER"
echo " Lockfile: $LOCKFILE"
exit 0
fi
if [[ $1 = "-e" ]]; then #configure
/bin/sh -c "${EDITOR:-vi} $0"
exit 0
fi
if [[ $1 = "-f" ]]; then # Friendica version
cd $FPATH
echo "You're currently on Friendica branch..."
echo "$(git branch)"
echo " Version number: ${bold}$(cat VERSION) ${normal}($(git log --oneline -n1 |cut -c 1-9))."
echo
echo "Checking available versions on github repository..."
echo
if command -v curl >/dev/null 2>&1 ; then
echo "Friendica branch 'master': $(curl -# https://raw.githubusercontent.com/friendica/friendica/master/VERSION)"
echo
echo "Friendica branch 'develop': $(curl -# https://raw.githubusercontent.com/friendica/friendica/develop/VERSION)"
else
if command -v wget >/dev/null 2>&1 ; then
echo "Friendica branch 'master': $(wget -O - -o /dev/null http://raw.githubusercontent.com/friendica/friendica/master/VERSION --show-progress)"
echo
echo "Friendica branch 'develop': $(wget -O - -o /dev/null http://raw.githubusercontent.com/friendica/friendica/develop/VERSION --show-progress)"
else
echo "[Error] 'curl' or 'wget' not found on your system."
fi
fi
exit 0
fi
if [[ $1 = "-u" ]]; then
if [[ $1 = "-u" && $2 = "-"* ]]; then # Check before override configuration
echo "Try 'fusig.sh --help' for more information."
exit 0
else
branch="$2"
fi
fi
(
flock -e 200 #Set lock
cd $FPATH
if [[ $1 = "-B" ]]; then # update db structure
echo "Updating database. This may take some time..."
if [[ $branch = "3.6" ]]; then
/bin/sh -c "scripts/dbstructure.php update"
else
/bin/sh -c "bin/console dbstructure update"
fi
exit 0
fi
echo "Switching core to branch '$branch'..."
git checkout $branch | print
echo "Updating Friendica core..."
git pull
cd $FPATH/addon
echo "Switching addons to branch '$branch'..."
git checkout $branch | print
echo "Updating Friendica addons..."
git pull
cd ..
echo "Installing with composer..."
exec 3>&1 1>>${FLOG} 2>&1
if [[ $(whoami) = $CUSER ]]; then
if [[ $branch = "3.6" ]]; then
util/composer.phar install --no-dev
echo "Git pull and util/composer.phar install successful at $(date)." | tee /dev/fd/3
else
bin/composer.phar install
echo "Git pull and bin/composer.phar install successful at $(date)." | tee /dev/fd/3
fi
else
if [[ $branch = "3.6" ]]; then
su $CUSER -s /bin/sh -c "util/composer.phar install --no-dev"
echo "Git pull and util/composer.phar install successful at $(date)." | tee /dev/fd/3
else
su $CUSER -s /bin/sh -c "bin/composer.phar install"
echo "Git pull and bin/composer.phar install successful at $(date)." | tee /dev/fd/3
fi
fi
echo "You're on Friendica ${bold}$(cat VERSION) ${normal}($(git log --oneline -n1 |cut -c 1-9))." | tee /dev/fd/3
) 200>${LOCKFILE}
exit 0