This commit is contained in:
Daniel Hansson 2022-12-25 18:32:29 +01:00 committed by GitHub
parent 294ed9ac5c
commit c01ca31e4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 72 deletions

View File

@ -83,7 +83,7 @@ This script will now exit. Please add a second disk and start over."
fi
# Get the name of the drive
DISKTYPE=$(fdisk -l | grep $DEVTYPE | awk '{print $2}' | cut -d ":" -f1 | head -1)
DISKTYPE=$(fdisk -l | grep "$DEVTYPE" | awk '{print $2}' | cut -d ":" -f1 | head -1)
if [ "$DISKTYPE" != "/dev/$DEVTYPE" ]
then
msg_box "It seems like your $SYSNAME secondary volume (/dev/$DEVTYPE) does not exist.
@ -180,7 +180,7 @@ format
# Do a backup of the ZFS mount
if is_this_installed libzfs4linux
then
if grep -r $POOLNAME /etc/mtab
if grep -r "$POOLNAME" /etc/mtab
then
install_if_not zfs-auto-snapshot
sed -i "s|date --utc|date|g" /usr/sbin/zfs-auto-snapshot
@ -191,8 +191,8 @@ fi
if zpool list -v | grep "$DEVTYPE"
then
check_command partprobe -s
zpool export $POOLNAME
zpool import -d /dev/disk/by-id $POOLNAME
zpool export "$POOLNAME"
zpool import -d /dev/disk/by-id "$POOLNAME"
fi
# Success!
@ -211,7 +211,7 @@ Manpage is here:
http://manpages.ubuntu.com/manpages/focal/man8/zfs-auto-snapshot.8.html
CURRENT STATUS:
$(zpool status $POOLNAME)
$(zpool status "$POOLNAME")
$(zpool list)"
fi

View File

@ -72,7 +72,7 @@ To upgrade to the latest version, please run: 'sudo bash $SCRIPTS/update.sh' fro
# Check if automated updates are set
REBOOT_SET=$(grep -r "shutdown -r" "$SCRIPTS"/update.sh)
# Check if it's older than 60 days (60 seconds * 60 minutes * 24 hours * 60 days)
if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - ((60*60*24*60)) ))" ]
if [ "$(stat --format=%Y "$SCRIPTS"/update.sh)" -le "$(( $(date +%s) - (60*60*24*60) ))" ]
then
print_text_in_color "$ICyan" "Downloading the latest update script..."
download_script STATIC update

View File

@ -132,8 +132,8 @@ run_script ADDONS locales
# Create new current user
download_script STATIC adduser
bash $SCRIPTS/adduser.sh "nextcloud_install_production.sh"
rm -f $SCRIPTS/adduser.sh
bash "$SCRIPTS"/adduser.sh "nextcloud_install_production.sh"
rm -f "$SCRIPTS"/adduser.sh
check_universe
check_multiverse
@ -475,7 +475,7 @@ then
while [ -z "$NCVERSION" ]
do
print_text_in_color "$ICyan" "Fetching the not-latest Nextcloud version..."
NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' \
NCVERSION=$(curl -s -m 900 "$NCREPO"/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' \
| sort --version-sort | grep -v "\.0$\|\.1$\|\.2$" | tail -1)
STABLEVERSION="nextcloud-$NCVERSION"
print_text_in_color "$IGreen" "$NCVERSION"
@ -497,7 +497,7 @@ rm "$HTML/$STABLEVERSION.tar.bz2"
# Secure permissions
download_script STATIC setup_secure_permissions_nextcloud
bash $SECURE & spinner_loading
bash "$SECURE" & spinner_loading
# Ask to set a custom username
if yesno_box_no "Nextcloud is about to be installed.\nDo you want to change the standard GUI user '$GUIUSER' to something else?"
@ -669,14 +669,14 @@ run_script ADDONS redis-server-ubuntu
# php"$PHPVER"-smbclient does not yet work in PHP 7.4
install_if_not libsmbclient-dev
yes no | pecl install smbclient
if [ ! -f $PHP_MODS_DIR/smbclient.ini ]
if [ ! -f "$PHP_MODS_DIR"/smbclient.ini ]
then
touch $PHP_MODS_DIR/smbclient.ini
touch "$PHP_MODS_DIR"/smbclient.ini
fi
if ! grep -qFx extension=smbclient.so $PHP_MODS_DIR/smbclient.ini
if ! grep -qFx extension=smbclient.so "$PHP_MODS_DIR"/smbclient.ini
then
echo "# PECL smbclient" > $PHP_MODS_DIR/smbclient.ini
echo "extension=smbclient.so" >> $PHP_MODS_DIR/smbclient.ini
echo "# PECL smbclient" > "$PHP_MODS_DIR"/smbclient.ini
echo "extension=smbclient.so" >> "$PHP_MODS_DIR"/smbclient.ini
check_command phpenmod -v ALL smbclient
fi
@ -696,14 +696,14 @@ echo "# igbinary for PHP"
echo "session.serialize_handler=igbinary"
echo "igbinary.compact_strings=On"
} >> "$PHP_INI"
if [ ! -f $PHP_MODS_DIR/igbinary.ini ]
if [ ! -f "$PHP_MODS_DIR"/igbinary.ini ]
then
touch $PHP_MODS_DIR/igbinary.ini
touch "$PHP_MODS_DIR"/igbinary.ini
fi
if ! grep -qFx extension=igbinary.so $PHP_MODS_DIR/igbinary.ini
if ! grep -qFx extension=igbinary.so "$PHP_MODS_DIR"/igbinary.ini
then
echo "# PECL igbinary" > $PHP_MODS_DIR/igbinary.ini
echo "extension=igbinary.so" >> $PHP_MODS_DIR/igbinary.ini
echo "# PECL igbinary" > "$PHP_MODS_DIR"/igbinary.ini
echo "extension=igbinary.so" >> "$PHP_MODS_DIR"/igbinary.ini
check_command phpenmod -v ALL igbinary
fi
restart_webserver
@ -715,7 +715,7 @@ yes | nextcloud_occ db:convert-filecache-bigint
nextcloud_occ db:add-missing-indices
while [ -z "$CURRENTVERSION" ]
do
CURRENTVERSION=$(sudo -u www-data php $NCPATH/occ status | grep "versionstring" | awk '{print $3}')
CURRENTVERSION=$(sudo -u www-data php "$NCPATH"/occ status | grep "versionstring" | awk '{print $3}')
done
if [ "${CURRENTVERSION%%.*}" -ge "19" ]
then
@ -733,7 +733,7 @@ install_if_not figlet
install_if_not ssl-cert
# Generate $HTTP_CONF
if [ ! -f $SITES_AVAILABLE/$HTTP_CONF ]
if [ ! -f "$SITES_AVAILABLE"/"$HTTP_CONF" ]
then
touch "$SITES_AVAILABLE/$HTTP_CONF"
cat << HTTP_CREATE > "$SITES_AVAILABLE/$HTTP_CONF"
@ -807,7 +807,7 @@ then
fi
# Generate $TLS_CONF
if [ ! -f $SITES_AVAILABLE/$TLS_CONF ]
if [ ! -f "$SITES_AVAILABLE"/"$TLS_CONF" ]
then
touch "$SITES_AVAILABLE/$TLS_CONF"
cat << TLS_CREATE > "$SITES_AVAILABLE/$TLS_CONF"
@ -1009,12 +1009,12 @@ then
fi
# Set secure permissions final (./data/.htaccess has wrong permissions otherwise)
bash $SECURE & spinner_loading
bash "$SECURE" & spinner_loading
# Put IP address in /etc/issue (shown before the login)
if [ -f /etc/issue ]
then
echo "\4" >> /etc/issue
printf '%s\n' "\4" >> /etc/issue
fi
# Fix Realtek on PN51

View File

@ -180,7 +180,7 @@ rm -f /root/db-migration.sh
# Fix bug in nextcloud.sh
CURRUSR="$(getent group sudo | cut -d: -f4 | cut -d, -f1)"
if [ -f $SCRIPTS/techandme.sh ]
if [ -f "$SCRIPTS/techandme.sh" ]
then
rm -f "$SCRIPTS/techandme.sh"
download_script STATIC nextcloud
@ -197,7 +197,7 @@ else
# Only update if it's older than 60 days (60 seconds * 60 minutes * 24 hours * 60 days)
if [ -f "$SCRIPTS"/nextcloud.sh ]
then
if [ "$(stat --format=%Y "$SCRIPTS"/nextcloud.sh)" -le "$(( $(date +%s) - ((60*60*24*60)) ))" ]
if [ "$(stat --format=%Y "$SCRIPTS"/nextcloud.sh)" -le "$(( $(date +%s) - (60*60*24*60) ))" ]
then
download_script STATIC nextcloud
chown "$CURRUSR":"$CURRUSR" "$SCRIPTS"/nextcloud.sh
@ -264,6 +264,7 @@ deleting any discovered nextcloud.log files and creating a new one at $VMLOGS/ne
chown www-data:www-data "$VMLOGS/nextcloud.log"
fi
}
find_log
if [ -d /var/log/ncvm/ ]
then
rsync -Aaxz /var/log/ncvm/ "$VMLOGS"
@ -292,9 +293,9 @@ else
fi
# Remove the local lib.sh since it's causing issues with new functions (2020-06-01)
if [ -f $SCRIPTS/lib.sh ]
if [ -f "$SCRIPTS"/lib.sh ]
then
rm -f $SCRIPTS/lib.sh
rm -f "$SCRIPTS"/lib.sh
fi
# Make sure everyone gets access to menu.sh
@ -401,15 +402,15 @@ then
sed -i "/extension=redis.so/d" "$PHP_INI"
fi
# Check if redis is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/redis.ini ]
if [ ! -f "$PHP_MODS_DIR"/redis.ini ]
then
touch $PHP_MODS_DIR/redis.ini
touch "$PHP_MODS_DIR"/redis.ini
fi
# Enable new redis
if ! grep -qFx extension=redis.so $PHP_MODS_DIR/redis.ini
if ! grep -qFx extension=redis.so "$PHP_MODS_DIR"/redis.ini
then
echo "# PECL redis" > $PHP_MODS_DIR/redis.ini
echo "extension=redis.so" >> $PHP_MODS_DIR/redis.ini
echo "# PECL redis" > "$PHP_MODS_DIR"/redis.ini
echo "extension=redis.so" >> "$PHP_MODS_DIR"/redis.ini
check_command phpenmod -v ALL redis
fi
@ -462,15 +463,15 @@ then
sed -i "/extension=igbinary.so/d" "$PHP_INI"
fi
# Check if igbinary is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/igbinary.ini ]
if [ ! -f "$PHP_MODS_DIR"/igbinary.ini ]
then
touch $PHP_MODS_DIR/igbinary.ini
touch "$PHP_MODS_DIR"/igbinary.ini
fi
# Enable new igbinary
if ! grep -qFx extension=igbinary.so $PHP_MODS_DIR/igbinary.ini
if ! grep -qFx extension=igbinary.so "$PHP_MODS_DIR"/igbinary.ini
then
echo "# PECL igbinary" > $PHP_MODS_DIR/igbinary.ini
echo "extension=igbinary.so" >> $PHP_MODS_DIR/igbinary.ini
echo "# PECL igbinary" > "$PHP_MODS_DIR"/igbinary.ini
echo "extension=igbinary.so" >> "$PHP_MODS_DIR"/igbinary.ini
check_command phpenmod -v ALL igbinary
fi
fi
@ -478,15 +479,15 @@ then
then
yes no | pecl upgrade smbclient
# Check if smbclient is enabled and create the file if not
if [ ! -f $PHP_MODS_DIR/smbclient.ini ]
if [ ! -f "$PHP_MODS_DIR"/smbclient.ini ]
then
touch $PHP_MODS_DIR/smbclient.ini
touch "$PHP_MODS_DIR"/smbclient.ini
fi
# Enable new smbclient
if ! grep -qFx extension=smbclient.so $PHP_MODS_DIR/smbclient.ini
if ! grep -qFx extension=smbclient.so "$PHP_MODS_DIR"/smbclient.ini
then
echo "# PECL smbclient" > $PHP_MODS_DIR/smbclient.ini
echo "extension=smbclient.so" >> $PHP_MODS_DIR/smbclient.ini
echo "# PECL smbclient" > "$PHP_MODS_DIR"/smbclient.ini
echo "extension=smbclient.so" >> "$PHP_MODS_DIR"/smbclient.ini
check_command phpenmod -v ALL smbclient
fi
# Remove old smbclient
@ -503,14 +504,14 @@ then
sed -i "/extension=inotify.so/d" "$PHP_INI"
fi
yes no | pecl upgrade inotify
if [ ! -f $PHP_MODS_DIR/inotify.ini ]
if [ ! -f "$PHP_MODS_DIR"/inotify.ini ]
then
touch $PHP_MODS_DIR/inotify.ini
touch "$PHP_MODS_DIR"/inotify.ini
fi
if ! grep -qFx extension=inotify.so $PHP_MODS_DIR/inotify.ini
if ! grep -qFx extension=inotify.so "$PHP_MODS_DIR"/inotify.ini
then
echo "# PECL inotify" > $PHP_MODS_DIR/inotify.ini
echo "extension=inotify.so" >> $PHP_MODS_DIR/inotify.ini
echo "# PECL inotify" > "$PHP_MODS_DIR"/inotify.ini
echo "extension=inotify.so" >> "$PHP_MODS_DIR"/inotify.ini
check_command phpenmod -v ALL inotify
fi
fi
@ -521,7 +522,7 @@ fi
restart_webserver
# Update adminer
if [ -d $ADMINERDIR ]
if [ -d "$ADMINERDIR" ]
then
print_text_in_color "$ICyan" "Updating Adminer..."
rm -f "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
@ -644,10 +645,10 @@ then
fi
# Update updatenotification.sh (gets updated after each nextcloud update as well; see down below the script)
if [ -f $SCRIPTS/updatenotification.sh ] && ! grep -q "Check for supported Nextcloud version" "$SCRIPTS/updatenotification.sh"
if [ -f "$SCRIPTS"/updatenotification.sh ] && ! grep -q "Check for supported Nextcloud version" "$SCRIPTS/updatenotification.sh"
then
download_script STATIC updatenotification
chmod +x $SCRIPTS/updatenotification.sh
chmod +x "$SCRIPTS"/updatenotification.sh
fi
# Update all Nextcloud apps
@ -698,7 +699,7 @@ lowest_compatible_nc 13
if [ -f /tmp/minor.version ]
then
NCBAD=$(cat /tmp/minor.version)
NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep "${CURRENTVERSION%%.*}" | tail -1)
NCVERSION=$(curl -s -m 900 "$NCREPO"/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep "${CURRENTVERSION%%.*}" | tail -1)
export NCVERSION
export STABLEVERSION="nextcloud-$NCVERSION"
rm -f /tmp/minor.version
@ -707,9 +708,9 @@ then
NCBAD=$(cat /tmp/nextmajor.version)
if [ "$NCNEXT" -lt "15" ]
then
NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep $NCNEXT | head -1)
NCVERSION=$(curl -s -m 900 "$NCREPO"/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep "$NCNEXT" | head -1)
else
NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep $NCNEXT | tail -1)
NCVERSION=$(curl -s -m 900 "$NCREPO"/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | grep "$NCNEXT" | tail -1)
fi
if [ -z "$NCVERSION" ]
then
@ -772,10 +773,10 @@ then
fi
# Update updatenotification.sh
if [ -f $SCRIPTS/updatenotification.sh ]
if [ -f "$SCRIPTS"/updatenotification.sh ]
then
download_script STATIC updatenotification
chmod +x $SCRIPTS/updatenotification.sh
chmod +x "$SCRIPTS"/updatenotification.sh
fi
############# Don't upgrade to specific version
@ -859,7 +860,7 @@ If you need support, please visit https://shop.hanssonit.se/product/upgrade-php-
fi
# Upgrade Nextcloud
if ! site_200 $NCREPO
if ! site_200 "$NCREPO"
then
msg_box "$NCREPO seems to be down, or temporarily not reachable. Please try again in a few minutes."
exit 1
@ -879,7 +880,7 @@ check_command systemctl stop apache2.service
# Create backup dir (/mnt/NCBACKUP/)
if [ ! -d "$BACKUP" ]
then
mkdir -p $BACKUP
mkdir -p "$BACKUP"
fi
# Backup PostgreSQL
@ -940,7 +941,7 @@ fi
# Backup data
for folders in config apps
do
if [[ "$(rsync -Aaxz $NCPATH/$folders $BACKUP)" -eq 0 ]]
if [[ "$(rsync -Aaxz "$NCPATH"/$folders "$BACKUP")" -eq 0 ]]
then
BACKUP_OK=1
else
@ -948,7 +949,7 @@ do
fi
done
if [ -z $BACKUP_OK ]
if [ -z "$BACKUP_OK" ]
then
msg_box "Backup was not OK. Please check $BACKUP and see if the folders are backed up properly"
exit 1
@ -967,7 +968,7 @@ else
exit 1
fi
if [ -d $BACKUP/config/ ]
if [ -d "$BACKUP"/config/ ]
then
print_text_in_color "$ICyan" "$BACKUP/config/ exists"
else
@ -976,7 +977,7 @@ Please check in $BACKUP if config/ folder exist."
exit 1
fi
if [ -d $BACKUP/apps/ ]
if [ -d "$BACKUP"/apps/ ]
then
print_text_in_color "$ICyan" "$BACKUP/apps/ exists"
echo
@ -986,13 +987,13 @@ then
"We will now start the update to Nextcloud $NCVERSION. $(date +%T)"
nextcloud_occ maintenance:mode --on
countdown "Removing old Nextcloud instance in 5 seconds..." "5"
rm -rf $NCPATH
rm -rf "$NCPATH"
print_text_in_color "$IGreen" "Extracting new package...."
check_command tar -xjf "$HTML/$STABLEVERSION.tar.bz2" -C "$HTML"
rm "$HTML/$STABLEVERSION.tar.bz2"
print_text_in_color "$IGreen" "Restoring config to Nextcloud..."
rsync -Aaxz $BACKUP/config "$NCPATH"/
bash $SECURE & spinner_loading
rsync -Aaxz "$BACKUP"/config "$NCPATH"/
bash "$SECURE" & spinner_loading
nextcloud_occ maintenance:mode --off
# Don't execute the update before all cronjobs are finished
check_running_cronjobs
@ -1002,7 +1003,7 @@ then
print_text_in_color "$ICyan" "Optimizing Nextcloud..."
yes | nextcloud_occ db:convert-filecache-bigint
nextcloud_occ db:add-missing-indices
CURRENTVERSION=$(sudo -u www-data php $NCPATH/occ status | grep "versionstring" | awk '{print $3}')
CURRENTVERSION=$(sudo -u www-data php "$NCPATH"/occ status | grep "versionstring" | awk '{print $3}')
if [ "${CURRENTVERSION%%.*}" -ge "19" ]
then
check_php
@ -1128,7 +1129,7 @@ print_text_in_color "$ICyan" "Setting RewriteBase to \"/\" in config.php..."
chown -R www-data:www-data "$NCPATH"
nextcloud_occ config:system:set htaccess.RewriteBase --value="/"
nextcloud_occ maintenance:update:htaccess
bash $SECURE & spinner_loading
bash "$SECURE" & spinner_loading
# Repair
nextcloud_occ maintenance:repair

View File

@ -126,5 +126,3 @@ You may have to change SPREED_WEBRTC_ORIGIN in:
(sudo nano) $NCPATH/apps/spreedme/config/config.php"
exit 0
fi
exit

View File

@ -54,7 +54,6 @@ Additional options and arguments:
-t Disable logging of blocklist hits in iptables
-h Display this help message
"
exit "$EXIT_CODE"
}
set_mode() {
@ -131,7 +130,7 @@ update_iptables() {
fi;
# iterate through all known spamming hosts
LASSOIP="$(cut -d ' ' -f1 $CACHE_FILE | tr -d ';' | awk 'NF > 0')"
LASSOIP="$(cut -d ' ' -f1 "$CACHE_FILE" | tr -d ';' | awk 'NF > 0')"
for IP in $LASSOIP; do
if [ $LOG_BLOCKLIST_HITS -eq 1 ]; then
# add the ip address log rule to the chain
@ -194,6 +193,7 @@ while getopts "c:l:f:usodtzh" option; do
h) # show usage information
usage
die
;;
:)