New version of AutoSWAP
This commit is contained in:
parent
76280be844
commit
5bd491033f
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
INSTALLERVERSION="1.1"
|
||||
INSTALLERVERSION="1.01.02"
|
||||
|
||||
if [[ $(whoami) != "root" ]]; then
|
||||
echo "You must be root to run this script!"
|
||||
|
@ -172,13 +172,13 @@ function doREPORT {
|
|||
echo "**Location of AutoSWAP configuration file:** /etc/autoswap/autoswap.conf" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
source /etc/autoswap/autoswap.conf
|
||||
echo "**Free system memory threshold:** $((threshold_minimum/1024)) GiB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**Free system memory threshold:** $threshold_minimum MB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**SWAP files size:** $((swap_file_size/1024)) GiB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**SWAP files size:** $swap_file_size MB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**Number of SWAP files that will permanently exist:** $required_swap_files" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**Minimum amount of harddrive space that must always exist:** $((minimum_free_storage/1024)) GiB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**Minimum amount of harddrive space that must always exist:** $minimum_free_storage MB" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo "**How often system memory is checked:** $check_interval seconds" >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
echo >> "NEXTCLOUD-REPORT-$TODAY.md"
|
||||
|
@ -210,9 +210,9 @@ function doREPORT {
|
|||
}
|
||||
|
||||
function doSWAP {
|
||||
wget "https://git.zaks.web.za/thisiszeev/linux-server-tools/releases/download/autoswap/autoswap-v1.01.zip" > /dev/null 2>> installer-errors.log || failMsg "Failed to download Auto SWAP..."
|
||||
wget "https://git.zaks.web.za/thisiszeev/linux-server-tools/releases/download/autoswap/autoswap-v1.01.01.zip" > /dev/null 2>> installer-errors.log || failMsg "Failed to download Auto SWAP..."
|
||||
mkdir autoswap
|
||||
unzip autoswap-v1.01.zip -d ./autoswap
|
||||
unzip autoswap-v1.01.01.zip -d ./autoswap
|
||||
mkdir /etc/autoswap
|
||||
mv ./autoswap/autoswap.conf /etc/autoswap/autoswap.conf
|
||||
mv ./autoswap/autoswap.sh /autoswap.sh
|
||||
|
@ -225,7 +225,7 @@ function doSWAP {
|
|||
mv ./autoswap/LICENSE /etc/autoswap/LICENSE
|
||||
mv ./autoswap/autoswap.service /etc/systemd/system/autoswap.service
|
||||
rm -R ./autoswap
|
||||
rm autoswap-v1.01.zip
|
||||
rm autoswap-v1.01.01.zip
|
||||
systemctl start autoswap.service > /dev/null 2>> installer-errors.log || failMsg "Auto SWAP service failed to start..."
|
||||
systemctl enable autoswap.service > /dev/null 2>> installer-errors.log || failMsg "Auto SWAP service could not be enabled..."
|
||||
}
|
||||
|
@ -886,6 +886,7 @@ function downloadUpdate {
|
|||
echo "Overwriting $SCRIPT with updated version..."
|
||||
cp "$0" "$ORIGINALSCRIPT" || echo "Overwrite failed..." >&2
|
||||
echo "Script updated successfully. Continuing execution..."
|
||||
sleep 2s
|
||||
}
|
||||
|
||||
function failMsg {
|
||||
|
@ -1076,11 +1077,11 @@ read input
|
|||
|
||||
echo "Updating system..."
|
||||
apt update > /dev/null 2>> installer-errors.log && apt -y upgrade > /dev/null 2>> installer-errors.log || failMsg "apt failed to update the system..."
|
||||
echo
|
||||
|
||||
if [[ ! -f position.temp ]]; then
|
||||
echo "1" > position.temp
|
||||
else
|
||||
echo
|
||||
echo "This script did not complete the installation in a prior attempt."
|
||||
echo "We will pickup from where it left off..."
|
||||
echo
|
||||
|
@ -1103,6 +1104,8 @@ if [[ $p -lt 3 ]]; then
|
|||
echo "Remote version could not be retrieved." >&2
|
||||
NEWVERSION="$INSTALLERVERSION"
|
||||
fi
|
||||
else
|
||||
NEWVERSION="$INSTALLERVERSION"
|
||||
fi
|
||||
if compareVersions "$INSTALLERVERSION" "$NEWVERSION" || [[ $SELF_UPDATED == 1 ]]; then
|
||||
downloadUpdate
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
if curl -s --head --request GET http://192.168.27.248 | grep "200 OK" > /dev/null; then
|
||||
echo "HTTP connection to example.com is available"
|
||||
else
|
||||
echo "HTTP connection to example.com failed"
|
||||
fi
|
||||
|
||||
if curl -s -k --head --fail https://192.168.27.248 > /dev/null; then
|
||||
echo "HTTPS connection to example.com is available (ignoring cert issues)"
|
||||
else
|
||||
echo "HTTPS connection to example.com failed"
|
||||
fi
|
Loading…
Reference in New Issue