-
Notifications
You must be signed in to change notification settings - Fork 0
/
media
executable file
·100 lines (86 loc) · 2.33 KB
/
media
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
99
100
#!/bin/bash
# Helper script to manage music and videos
# Copyright (C) 2015 Scott Weldon
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
validArgs=("rootdir" "server")
source loadconf "$HOME/.scott_script/media" "config" validArgs[@]
[ -z "$rootdir" ] && echo "Root directory not defined!" && exit 1
if [ ! -d "$rootdir" ]
then
read -p "Root directory ($rootdir) does not exist. Create it? [y/N]" response
if [ "$response" == "Y" ] || [ "$response" == "y" ]
then
mkdir -p "$rootdir"
else
echo "Not creating root directory. Exiting..."
exit 2
fi
fi
cd "$rootdir"
echo "Checking existence of subdirectories (music, movies)"
if [ ! -d "$rootdir/music" ]
then
echo "Subdir music not found, creating..."
mkdir "$rootdir/music"
fi
if [ ! -d "$rootdir/movies" ]
then
echo "Subdir movies not found, creating..."
mkdir "$rootdir/movies"
fi
function sync() {
echo "Syncing with server..."
server $server sync-dry "$rootdir/" "$rootdir/"
echo "If there is anything to sync, and it looks correct, please press [y/Y]"
echo "to sync it. Otherwise, press Enter to continue."
read -p "Press [y/Y/Enter]: " response
if [ "$response" == "Y" ] || [ "$response" == "y" ]
then
server $server sync
else
echo "Not syncing."
fi
}
function music() {
echo "FIXME"
}
function movies() {
echo "FIXME"
}
while true
do
echo "What do you want to do?"
echo " 1) Download music."
echo " 2) Download movies."
echo
echo " s) Sync local files to server."
echo
echo " q) Quit."
read -p "Press [1/2/s/q]: " response
case $response in
"1")
music
;;
"2")
movies
;;
"s")
sync
;;
"q")
break
;;
*)
echo "Invalid option ($response). Please try again."
;;
esac
done