Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F1820825
LimeSurvey update script for system administrators
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
valerio.bozzolan
Sep 22 2023, 10:09
2023-09-22 10:09:19 (UTC+2)
Size
4 KB
Referenced Files
None
Subscribers
None
LimeSurvey update script for system administrators
View Options
#!/bin/sh
##################################################################
# LimeSurvey command line update script for system administrators.
#
# IMPORTANT: Please donate to LimeSurvey!
#
# Author: Valerio Bozzolan
# License: GNU GPL v3+
# Date: 2023
# Source code: https://gitpull.it/P24
##################################################################
set -e
#
# CONFIGURATION STARTS HERE! \o/
#
# URL of your LimeSurvey.
url="https://survey.wikimedia.ch"
# Parent directory of your LimeSurvey installation.
base="/var/www/wikimedia.ch/limesurvey"
# Temporary directory used to download stuff.
temp="/var/www/wikimedia.ch/limesurvey/tmp"
# Database name to be backupped.
dbname="limesurvey_production"
# Symbolic link that is supposed to point to the specific LimeSurvey version to be adopted.
# I organized in such way my filesystem, so "www" points to "limesurvey-1.2.3" and I can
# swap whenever I want.
production_symlink="/var/www/wikimedia.ch/limesurvey/www"
# Script that will be executed just before promoting the new version to production.
# In my case this scripts sets some files as "root:root" so are not writable, and some
# other files are assigned to the webserver user. Essentially it depends by you.
harden_script="/root/scripts/limesurvey-harden.sh"
# Services that will be restarted just after promoting the new version to production.
services_to_be_restarted="php7.3-fpm"
#
# CONFIGURATION ENDS HERE! \o/
#
# No hardening, no party.
if ! [ -x "$harden_script" ]; then
echo "The post-install script (hardening script) does not exist or is not executable."
echo " $harden_script"
exit 2
fi
# No symbolic link, no party.
if ! [ -L "$production_symlink" ]; thenù
echo "This path is supposed to be a symbolic link. Not applicable."
echo " $production_symlink"
exit 2
fi
# https://download.limesurvey.org/latest-stable-release/limesurvey5.2.5+211207.zip
lime_zip_url="$1"
# no lime_zip_url no party
if [ -z "$lime_zip_url" ]; then
echo "Missing download ZIP URL"
echo "Go here: https://community.limesurvey.org/downloads/"
echo "And paste the ZIP URL as first parameter"
exit 1
fi
# no lime_zip_url no party
lime_version="$2"
if [ -z "$lime_version" ]; then
echo "Please add the version code as second parameter"
echo "E.g. 5.4.1"
exit 2
fi
lime_version="limesurvey-$lime_version"
lime_version_base="$base/$lime_version"
lime_version_tmp="$temp/$lime_version"
lime_version_tmp_zip="$temp/$lime_version.zip"
# Do not re-extract over an already-existing LimeSurvey.
if [ -d "$lime_version_tmp" ]; then
echo "This path already exists. Please remove it before using as download destination:"
echo " $lime_version_tmp"
exit 1
fi
# download
echo "Downloading"
wget "$lime_zip_url" -O "$lime_version_tmp_zip"
# print firm
md5sum "$lime_version_tmp_zip"
sha1sum "$lime_version_tmp_zip"
sha256sum "$lime_version_tmp_zip"
# backup
echo "Backup database"
mysqldump "$dbname" > "$temp/$dbname-$lime_version.sql"
# extract
echo "Extraction"
mkdir --parents "$lime_version_tmp"
unzip "$lime_version_tmp_zip" -d "$lime_version_tmp"
# swap /limesurvey-123/limesurvey to just /limesurvey
echo "Preparation"
mv --no-target-directory "$lime_version_tmp/limesurvey" "$lime_version_base"
echo "Import config and upload"
cp --archive "$production_symlink/application/config/security.php" "$lime_version_base/application/config/security.php"
cp --archive "$production_symlink/application/config/config.php" "$lime_version_base/application/config/config.php"
cp --archive "$production_symlink/upload" "$lime_version_base/upload"
echo "Hardening"
$harden_script "$lime_version_base"
echo "Push in production"
rm --verbose "$production_symlink"
ln --verbose --symbolic --no-dereference "$lime_version_base" "$production_symlink"
# clean downloaded file
echo "Clean"
rmdir "$lime_version_tmp"
rm "$lime_version_tmp_zip"
echo "Now please update from your web interface"
echo "$url"
echo "Remember to clean this backup:"
echo " $temp/$dbname-$lime_version.sql"
echo "Restarting $services_to_be_restarted"
systemctl restart "$services_to_be_restarted"
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
271515
Default Alt Text
LimeSurvey update script for system administrators (4 KB)
Attached To
Mode
P24 LimeSurvey update script for system administrators
Attached
Detach File
Event Timeline
Log In to Comment