summaryrefslogtreecommitdiff
path: root/support/tikztosvg/install.sh
blob: bc5a26741b918ae7570739945cd10f59fbf845ec (plain)
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
#!/bin/sh

puts ()
{
    printf "\033[1m\033[38;5;%sm[%s]\033[m %s\n\n" "$3" "$1" "$2"
}

error ()
{
    puts ERROR "$1" 9
    exit 1
}

dependencyWarning () 
{
    puts WARNING "$(printf "The command '%s' could not be found.\nPlease make sure it is included in the \$PATH enviroment variable or follow the installation instructions on %s." "$1" "$2")" 3
}

message ()
{
    puts INSTALLER "$1" 2
}

if [ "$(id -u)" -ne "0" ]
then
    error "This script requires administrator-privileges"
fi

if ! [ -x "$(command -v xelatex)" ]
then
    dependencyWarning "xelatex" "https://tug.org/texlive/"
fi

if ! [ -x "$(command -v pdf2svg)" ]
then
    dependencyWarning "pdf2svg" "https://github.com/dawbarton/pdf2svg"
fi

message "Installing tikztosvg(1)"

if [ -f "$HOME/.local/bin/tikztosvg" ]
then
    rm "$HOME/.local/bin/tikztosvg"
fi

wget https://gitlab.com/pablo-escobar/tikztosvg/-/raw/master/tikztosvg -P "$HOME/.local/bin/"\
    && chmod +x "$HOME/.local/bin/tikztosvg"\
    || exit 1

tmp="$(mktemp -d)"
message "Installing manual entry for tikztosvg(1)"
wget https://gitlab.com/pablo-escobar/tikztosvg/-/raw/master/man/tikztosvg.1 -P "$tmp"\
    && install -g 0 -o 0 -m 0644 "$tmp/tikztosvg.1" "$HOME/.local/share/man/man1/"\
    || exit 1

if [ -f "$HOME/.local/share/man/man1/tikztosvg.1.gz" ]
then
    rm "$HOME/.local/share/man/man1/tikztosvg.1.gz"
fi

gzip "$HOME/.local/share/man/man1/tikztosvg.1"
rm "$tmp" -r