-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
92 lines (84 loc) · 2.64 KB
/
install.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
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
#!/usr/bin/env bash
# exit statuses:
# 0 - installed successfully
# 1 - missing program
# 2 - missing library
# 3 - cd error
# 100 - not run as root
if command -v qoi-thumbnail >/dev/null;then
echo ".qoi thumbnailer allready installed"
echo "not about to re-install it"
exit 0
fi
if [[ ! $(id -u) = "0" ]];then
echo "Script needs to be ran as root"
exit 100
fi
if command -v update-mime-database >/dev/null;then
echo "update-mime-database found"
else
echo "update-mime-database not found on path. install it"
exit 1
fi
if command -v convert >/dev/null;then
if convert -h | head -n1 | grep "ImageMagick";then
echo "'convert' from ImageMagick is installed"
else
echo "'convert' is installed but it is not ImageMagick. please put the ImageMagick one on path"
echo "or install the package `imagemagick`"
exit 1
fi
else
echo "'convert' from ImageMagick is not installed"
echo "install it from the package `imagemagick`"
exit 1
fi
hme="$PWD"
if command -v qoiconv >/dev/null;then
echo "found qoiconv on path"
else
echo "qoiconv not found, checking git and gcc"
missing_gcc="y"
missing_git="y"
missing_stb="y"
if command -v git >/dev/null;then
missing_git="n"
fi
if command -v gcc >/dev/null;then
missing_gcc="n"
fi
if [[ -d "/usr/include/stb" ]];then
missing_stb="n"
fi
if [[ "$missing_git" = "n" && "$missing_gcc" = "n" && "$missing_stb" = "n" ]];then
echo "found git, gcc and libstb. installing qoiconv"
mkdir -p /usr/local/opt
cd /usr/local/opt || exit 3
git clone "https://github.com/phoboslab/qoi"
cd qoi || exit 3
gcc qoiconv.c -std=c99 -O3 -o qoiconv -I/usr/include/stb
ln -fs "$PWD/qoiconv" "/usr/local/bin/"
echo "qoiconv installed"
else
echo "missing either git, gcc, and/or libstb."
echo "missing git: $missing_git"
echo "missing gcc: $missing_gcc"
echo "missing libstb: $missing_stb"
exit 1
fi
fi
cd "$hme" || exit 3
echo "quickly chmod x ing the thumbnailer script just in case"
chmod x ./qoi-thumbnail
echo "copying thumbnailer script to /usr/local/bin"
cp ./qoi-thumbnailer/qoi-thumbnailer/local/bin/qoi-thumbnail "/usr/local/bin"
echo "copying .thumbnailer file to /usr/share/thumbnailers"
cp ./qoi-thumbnailer/qoi-thumbnailer/share/thumbnailers/qoi.thumbnailer "/usr/share/thumbnailers"
echo "copying x-qoi.xml to /usr/local/share/mime/packages"
cp ./qoi-thumbnailer/qoi-thumbnailer/share/mime/packages/x-qoi.xml "/usr/local/share/mime/packages"
echo "updateing mime database"
update-mime-database "/usr/local/share/mime"
echo "installing magic number (so 'qoi' images can be picked up via the 'file' command)"
echo "0 string qoif image/x-qoi" >> /etc/magic
echo "!:mime image/x-qoi" >> /etc/magic
echo "Done"