forked from Sophia/thelinuxlist
40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Function to perform uninstallation
|
|
uninstall_gitea() {
|
|
echo "Stopping Gitea service..."
|
|
sudo systemctl stop gitea
|
|
|
|
echo "Disabling Gitea service..."
|
|
sudo systemctl disable gitea
|
|
|
|
echo "Removing Gitea service file..."
|
|
sudo rm -rf /etc/systemd/system/gitea.service
|
|
|
|
echo "Backing up files..."
|
|
timestamp=$(date +"%Y%m%d_%H%M%S")
|
|
tar -cvzf "gitea_backup_${timestamp}.tar.gz" /var/lib/gitea/ /etc/gitea || { echo "Failed to backup files. Exiting."; exit 1; }
|
|
|
|
echo "Removing Gitea user and home directory..."
|
|
sudo userdel -r git || { echo "Failed to delete Gitea user. Exiting."; exit 1; }
|
|
|
|
echo "Removing Gitea binary..."
|
|
sudo rm -rf /usr/local/bin/gitea
|
|
|
|
echo "Cleaning up Gitea data and configuration..."
|
|
sudo rm -rf /var/lib/gitea/* /etc/gitea
|
|
|
|
echo "Removing firewall rule for port 3000..."
|
|
sudo ufw delete allow 3000
|
|
|
|
echo "Gitea has been uninstalled, and all files have been backed up."
|
|
}
|
|
|
|
# Main script
|
|
trap 'exit 130' INT
|
|
|
|
# Automate confirmation by assuming yes to the prompt
|
|
uninstall_gitea
|
|
|
|
exit 0
|