-
Notifications
You must be signed in to change notification settings - Fork 2
/
.template_env
98 lines (85 loc) · 3.18 KB
/
.template_env
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## ---------------------- FOLDERS SETUP
## PLEASE READ: * Locations MUST END with '/'
## * Locations MUST BE FULL path '/root/of/files/'
## * rsync will send CONTENTS of source to ROOT of dest.
## ( ex: /my/use/files/* --> /my/bkp/files/ )
## * Locations MUST EXIST prior to running scripts
## audio subsection
AUDIOROOT="/mnt/vault/music/"
AUDIOBACKUP="/mnt/vault/music_bkp/"
AUDIOJUNK="/mnt/vault/music/.converted_audio/"
## all videos subsection
VIDEOSJUNK="/mnt/vault/videos/.converted_videos/"
## series subsection
SERIESROOT="/mnt/vault/videos/series/"
SERIESBACKUP="/mnt/vault/videos_bkp/series/"
## movies subsection
MOVIESROOT="/mnt/vault/videos/movies/"
MOVIESBACKUP="/mnt/vault/videos_bkp/movies/"
## concerts subsection
CONCERTSROOT="/mnt/vault/videos/shows/"
CONCERTSBACKUP="/mnt/vault/videos_bkp/shows/"
## stand-up subsection
STANDUPROOT="/mnt/vault/videos/standup/"
STANDUPBACKUP="/mnt/vault/videos_bkp/standup/"
## permissions
AUDIO_OWNER="lidarr"
SERIES_OWNER="sonarr"
MOVIES_OWNER="radarr"
CONCERTS_OWNER="radarr"
STANDUP_OWNER="radarr"
GROUP="goodies"
## ------------------------ SCRIPT SETTINGS (auto)
## bash colors
HEAD='\033[34;1m' #blue
OK='\033[0;32m' #green
WARN='\033[1;33m' #yellow
ERROR='\033[0;31m' #red
NC='\033[0m' #no color
BANNER=$(echo -e "toilet -t -F border -F metal -f smblock Bash Media Manager")
## ------------------------- FUNCTIONS
# Check if a package is installed and offer to install it if not.
# Usage: dep_check <package_name>
dep_check() {
local package_name="$1"
if dpkg -l | grep -q -E "^ii[[:space:]]+$package_name"; then
echo -e "$package_name: ${OK}Found${NC}"
else
echo -e "${ERROR}$package_name not found!${NC} Install package(s)? (Y/n) \c"
read -r yesno < /dev/tty
if [[ "$yesno" =~ ^[Yy]$ ]]; then
if [ "$(id -u)" -ne 0 ]; then
echo -e "${ERROR}You need sudo privileges to install packages.${NC}"
echo -e "Manually install with 'sudo apt-get install $package_name'"
return 1
fi
sudo apt-get update
sudo apt-get install "$package_name" -y
else
echo -e "${WARN}Cannot continue without $package_name package!"
echo -e "Manually install with 'sudo apt-get install $package_name'"
echo -e "Aborting...${NC}"
return 1
fi
fi
}
# Check if a directory exists, and optionally create it after user confirmation.
# Usage: dir_check <directory_path>
dir_check() {
local dir_path="$1"
if [[ -d "$dir_path" ]]; then
echo -e "${WARN}$dir_path: ${OK}Found${NC}" && return 0
else
echo -e "${WARN}$dir_path: ${ERROR}NOT FOUND${NC}"
read -p "Do you want to create $dir_path? (y/n): " create_dir
if [[ "$create_dir" =~ ^[Yy]$ ]]; then
mkdir -p "$dir_path" && echo -e "${WARN}$dir_path: ${OK}NOW CREATED${NC}" || {
echo -e "${ERROR}Could not create ${WARN}$dir_path${NC}, please check permissions or create them manually."
return 1
}
else
echo "Operation canceled."
return 2
fi
fi
}