UpdateAuthelia.sh: Difference between revisions

From FlowerHouseWiki
(Created page with "<syntaxhighlight lang="bash" line> #!/bin/bash # Variables name="Authelia" repo="authelia/authelia" architecture="linux-amd64" binary_path="/usr/bin" binary_name="authelia" # ===== VERSION CHECKING, CUSTOMIZE VARIBLES FOR IT ===== # Get current version current=$($binary_path/$binary_name --version) # Retain everything after last space current=${current##* } # Get latest release tag latest=$(curl -sL https://api.github.com/repos/$repo/releases/latest | jq -r ".tag_n...")
 
No edit summary
 
Line 5: Line 5:
name="Authelia"
name="Authelia"
repo="authelia/authelia"
repo="authelia/authelia"
architecture="linux-amd64"
architecture="amd64"


binary_path="/usr/bin"
binary_path="/usr/bin"
Line 32: Line 32:
if (("${current//[!0-9]/}" > "${latest//[!0-9]/}")); then
if (("${current//[!0-9]/}" > "${latest//[!0-9]/}")); then
echo -e "-------------------------------------------------------------------------------------------"
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Installed ${current} is newer than available version, repository deprecated?"
echo -e "- Installed ${current} is newer than available version ${latest}, repository deprecated?"
echo -e "-------------------------------------------------------------------------------------------"
echo -e "-------------------------------------------------------------------------------------------"
exit 0
exit 0
Line 52: Line 52:
# ===== INSTALLATION PART, CUSTOMIZE FOR EACH SOFTWARE =====
# ===== INSTALLATION PART, CUSTOMIZE FOR EACH SOFTWARE =====
# Download files
# Download files
wget https://github.com/authelia/authelia/releases/download/v4.35.2/authelia-${latest}-${architecture}.tar.gz || exit 1
wget https://github.com/authelia/authelia/releases/download/${latest}/authelia_${latest}_${architecture}.deb || exit 1


# Untar files
# Install software
tar -xvf authelia-${latest}-${architecture}.tar.gz || exit 1
apt install ./authelia_${latest}_${architecture}.deb || exit 1
 
# Stop software
systemctl stop authelia || exit 1
 
# Move files
mv authelia-linux-amd64 /usr/bin/authelia || exit 1
mv config.template.yml /etc/authelia/config.template.yml || exit 1
mv authelia.service /etc/systemd/system/ || exit 1
 
# Set permission
chmod 775 /usr/bin/authelia || exit 1
chown root:root /usr/bin/authelia || exit 1
 
# Update systemctl daemon
systemctl daemon-reload || exit 1
 
# Start authelia
systemctl start authelia || exit 1


# Remove old files
# Remove old files
rm authelia-${latest}-${architecture}.tar.gz || exit 1
rm authelia_${latest}_${architecture}.deb || exit 1


# ===== FINISH INSTALLATION SCRIPT ====
# ===== FINISH INSTALLATION SCRIPT ====

Latest revision as of 21:58, 28 July 2022

#!/bin/bash

# Variables
name="Authelia"
repo="authelia/authelia"
architecture="amd64"

binary_path="/usr/bin"
binary_name="authelia"

# ===== VERSION CHECKING, CUSTOMIZE VARIBLES FOR IT =====

# Get current version
current=$($binary_path/$binary_name --version)

# Retain everything after last space
current=${current##* }

# Get latest release tag
latest=$(curl -sL https://api.github.com/repos/$repo/releases/latest | jq -r ".tag_name")

# Check if new version available
if (("${current//[!0-9]/}" == "${latest//[!0-9]/}")); then
	echo -e "-------------------------------------------------------------------------------------------"
	echo -e "- Installed ${current} is up to date"
	echo -e "-------------------------------------------------------------------------------------------"
	exit 0
fi

# Check if repo is deprecated
if (("${current//[!0-9]/}" > "${latest//[!0-9]/}")); then
	echo -e "-------------------------------------------------------------------------------------------"
	echo -e "- Installed ${current} is newer than available version ${latest}, repository deprecated?"
	echo -e "-------------------------------------------------------------------------------------------"
	exit 0
fi

# Write information
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update ${name} ${current} to ${latest}?"
echo -e "-------------------------------------------------------------------------------------------"

echo -e -n "Continue? [y/N]"
echo ""
read -n 1 c

if [ "${c}" != "y" ]; then
	exit 0
fi

# ===== INSTALLATION PART, CUSTOMIZE FOR EACH SOFTWARE =====
# Download files
wget https://github.com/authelia/authelia/releases/download/${latest}/authelia_${latest}_${architecture}.deb || exit 1

# Install software
apt install ./authelia_${latest}_${architecture}.deb || exit 1

# Remove old files
rm authelia_${latest}_${architecture}.deb || exit 1

# ===== FINISH INSTALLATION SCRIPT ====
echo -e "-------------------------------------------------------------------------------------------"
echo -e "- Update to ${latest} completed!"
echo -e "-------------------------------------------------------------------------------------------"