-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink-prednasky.sh
executable file
·58 lines (50 loc) · 953 Bytes
/
link-prednasky.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
57
58
#!/bin/bash
VIDEO_DIR=/home/shared/lectures
SEM_DIR=$HOME/school/sem/
show_help()
{
echo -e "Usage: progname <command> [command-options]\n"
echo """Commands:
run make missing links
help this message"""
}
get_cr_dir()
{
NAME=$(grep "$1" ~/school/courses | cut -d' ' -f2)
[[ $NAME ]] && echo $SEM_DIR/$NAME
}
# make video link for each course with
# video files in current term
run()
{
for CR in $VIDEO_DIR/*; do
CR=${CR#"$VIDEO_DIR/"}
[[ $DEBUG ]] && echo "trying $CR"
CR_DIR=$(get_cr_dir $CR)
if [[ $CR_DIR = "" ]]; then
[[ $DEBUG ]] && echo "code $CR is not valid"
continue
fi
if [[ ! -L "$CR_DIR/video" ]]; then
cd "$CR_DIR"
ln -s "$VIDEO_DIR/$CR" video
cd - > /dev/null
fi
done
}
#
# main
#
if [[ $# = 0 ]]; then
show_help
exit
fi
# debug mode
if [[ $1 = "-d" ]]; then
DEBUG=echo
shift
fi
case $1 in
-h|--help|help) show_help;;
run) run;;
esac