-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathenterprise-linux-uninstall.sh
executable file
·56 lines (38 loc) · 1.99 KB
/
enterprise-linux-uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# prompt user for the name of the database
read -p "What is the name of the database for which you'd like to stop automatically backing up and optimizing? " dbname
# confirm that the name of the database is correct
echo "You entered: $dbname"
read -p "Is that correct? Enter y or no: " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
# stop backup systemd timer
systemctl stop backup-"$dbname".timer
# stop backup systemd service
systemctl stop backup-"$dbname".service
# stop optimize systemd timer
systemctl stop optimize-"$dbname".timer
# stop optimize systemd service
systemctl stop optimize-"$dbname."service
# disable backup systemd timer
systemctl disable backup-"$dbname".timer
# disable backup systemd service
systemctl disable backup-"$dbname".service
# disable optimize systemd timer
systemctl disable optimize-"$dbname".timer
# disable optimize systemd service
systemctl disable optimize-"$dbname".service
# remove backup systemd timer file
rm /etc/systemd/system/backup-"$dbname".timer
# remove backup systemd service file
rm /etc/systemd/system/backup-"$dbname".service
# remove optimize systemd timer file
rm /etc/systemd/system/optimize-"$dbname".timer
# remove optimize systemd service file
rm /etc/systemd/system/optimize-"$dbname".service
# remove backup shell script
rm /usr/local/DaVinci-Resolve-PostgreSQL-Workflow-Tools/backup/backup-"$dbname".sh
# remove optimize shell script
rm /usr/local/DaVinci-Resolve-PostgreSQL-Workflow-Tools/optimize/optimize-"$dbname".sh
# log to monthly log file that $dbname has been uninstalled. $dbname will no longer be backed up or optimized
echo "Backup and optimize tools for $dbname were uninstalled at $(date "+%Y_%m_%d_%H_%M"). $dbname will no longer be backed up or optimized." >> /usr/local/DaVinci-Resolve-PostgreSQL-Workflow-Tools/logs/logs-$(date "+%Y_%m").log
# send message to user in command-line program to inform them of the same
echo "Backup and optimize tools for ${dbname} were uninstalled. Have a great day!"