Skip to content

Commit 1cf696a

Browse files
committed
Merge branch 'master' into dev
2 parents fd06434 + 7fc0d47 commit 1cf696a

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

ci/bundle_install.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if [ "$EUID" -ne 0 ]; then
3333
exit
3434
fi
3535

36-
if ! [[ -d /run/systemd/system ]]; then
36+
if [ ! -d /run/systemd/system ]; then
3737
failWithError "Your system is not running systemd. As this installer relies on systemd services to run daemons, it's of no use on your system. You will have to install Smithereen manually."
3838
fi
3939

@@ -61,11 +61,13 @@ if ! [ -x "$(command -v mysql)" ]; then
6161
If you would like to run the database on a separate server, you will have to install Smithereen manually."
6262
fi
6363
mysqlVersion="$(mysql --version | tr -s " ")"
64-
if [ "$(echo $mysqlVersion | grep MariaDB | wc -l)" -gt "0" ]; then
64+
echo $mysqlVersion | grep -q MariaDB
65+
if [ "$?" ]; then
6566
failWithError "You have MariaDB instead of MySQL. Unfortunately, some distribution maintainers think that it's a drop-in replacement, but MariaDB is known to be incompatible with Smithereen.
6667
See $mysqlHelpUrl for instructions on how to install MySQL, or, if you need MariaDB for other applications on your server, consider running Smithereen in a container like Docker or LXC."
6768
fi
68-
if [ "$(echo $mysqlVersion | grep Distrib | wc -l)" -gt "0" ]; then
69+
echo $mysqlVersion | grep -q Distrib
70+
if [ "$?" ]; then
6971
mysqlActualVersion="$(echo $mysqlVersion | cut -d " " -f 5)"
7072
else
7173
mysqlActualVersion="$(echo $mysqlVersion | cut -d " " -f 3)"
@@ -108,7 +110,8 @@ fi
108110
read -p "Database name and new MySQL user name [smithereen]: " dbName
109111
if [ -z "$dbName" ]; then dbName="smithereen"; fi
110112
read -p "Would you like to use an S3 cloud storage service for user-uploaded files (y/n)? [n]: " useS3
111-
if [ "$useS3" == [yY] ]; then
113+
echo "$useS3" | grep -q '[yY]'
114+
if [ "$?" ]; then
112115
echo ""
113116
echo "Make sure you've read the readme and configured your storage service correctly: https://github.com/grishka/Smithereen/blob/master/README.md#using-s3-object-storage"
114117
echo ""
@@ -140,13 +143,13 @@ read -p "Press Enter to continue..."
140143
echo ""
141144
mkdir -p $installLocation || failWithError "Unable to create directory $installLocation"
142145
mkdir -p $installLocation/nginx_cache/images
143-
mkdir -p $webRoot
146+
mkdir -p $webRoot || failWithError "Unable to create directory $webRoot"
144147
mkdir $webRoot/s
145148
mkdir $webRoot/s/uploads
146149
mkdir $webRoot/s/media_cache
147-
chown -R www-data:www-data $webRoot
148-
chown -R www-data:www-data $installLocation/nginx_cache/images
149-
cp -v -R smithereen.jar lib libvips* imgproxy $installLocation
150+
chown -R www-data:www-data $webRoot || failWithError "Unable to change owner of $webRoot"
151+
chown -R www-data:www-data $installLocation/nginx_cache/images || failWithError "Unable to change owner of $installLocation/nginx_cache/images"
152+
cp -v -R smithereen.jar lib libvips* imgproxy $installLocation || failWithError "Unable to copy files to the $installLocation"
150153
151154
echo "Creating database..."
152155
echo "CREATE DATABASE $dbName;" | $mysqlCommand > /dev/null || failWithError "Unable to create a MySQL database"
@@ -167,7 +170,8 @@ db.password=$mysqlUserPassword
167170
168171
# The domain for your instance. Used for local object URIs in ActivityPub. If running on localhost, must include the port.
169172
domain=$domain"
170-
if [ "$useS3" == [yY] ]; then
173+
echo "$useS3" | grep -q '[yY]'
174+
if [ "$?" ]; then
171175
configContent="$configContent
172176
173177
# S3 storage configuration
@@ -188,7 +192,8 @@ upload.s3.bucket=$s3Bucket"
188192
configContent="$configContent
189193
upload.s3.hostname=$s3Hostname"
190194
fi
191-
if [ $s3OverridePathStyle == [yY] ]; then
195+
echo "$s3OverridePathStyle" | grep -q '[yY]'
196+
if [ "$?" ]; then
192197
configContent="$configContent
193198
upload.s3.override_path_style=true"
194199
fi
@@ -228,11 +233,14 @@ imgproxy.key=$imgproxyKey
228233
imgproxy.salt=$imgproxySalt"
229234
230235
echo "$configContent" > "$installLocation/config.properties"
231-
echo "IMGPROXY_KEY=$imgproxyKey
236+
cat <<EOF > "$installLocation/imgproxy.env"
237+
$imgproxyKey
232238
IMGPROXY_SALT=$imgproxySalt
233239
IMGPROXY_PATH_PREFIX=/i
234-
IMGPROXY_LOCAL_FILESYSTEM_ROOT=$webRoot/s" > "$installLocation/imgproxy.env"
235-
if [ "$useS3" == [yY] ]; then
240+
IMGPROXY_LOCAL_FILESYSTEM_ROOT=$webRoot/s
241+
EOF
242+
echo "$useS3" | grep -q '[yY]'
243+
if [ "$?" ]; then
236244
if [ -z "$s3Hostname" ]; then s3Hostname="s3-$s3Region.amazonaws.com"; fi
237245
echo "IMGPROXY_ALLOWED_SOURCES=local://,https://$s3Hostname/" >> "$installLocation/imgproxy.env"
238246
else

ci/bundle_update.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#!/bin/bash
22

3+
function failWithError {
4+
echo -e "\033[1;31mError:\033[0m $1" >&2
5+
exit 1
6+
}
7+
38
cd $(dirname $0)
49

510
installLocation=$1
611
if [ -z "$installLocation" ]; then installLocation="/opt/smithereen"; fi
712

813
if [[ ! -d $installLocation ]]; then
9-
echo "$installLocation does not exist."
10-
exit 1
14+
failWithError "$installLocation does not exist."
1115
fi
1216
if [[ ! -f "$installLocation/smithereen.jar" ]]; then
13-
echo "$installLocation does not appear to contain a Smithereen installation."
14-
exit 1
17+
failWithError "$installLocation does not appear to contain a Smithereen installation."
1518
fi
1619

1720
echo "This script will now:"
@@ -24,7 +27,7 @@ service smithereen stop
2427
service smithereen_imgproxy stop
2528

2629
rm -rf "$installLocation/lib"
27-
cp -v -R smithereen.jar lib libvips* imgproxy $installLocation
30+
cp -v -R smithereen.jar lib libvips* imgproxy $installLocation || failWithError "Unable to copy files to the $installLocation"
2831

2932
service smithereen start
3033
service smithereen_imgproxy start

0 commit comments

Comments
 (0)