-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·37 lines (30 loc) · 999 Bytes
/
setup.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
#!/usr/bin/env bash
setup() {
local prefix="$1";
local curdir="$(pwd)";
local py_ver="$(ls /usr/bin | grep -E '^python[0-9][.][0-9]+$' | tr '\n' ' ' | cut -d ' ' -f1)";
local pattern="^[/]";
if [ ! "${prefix}" ] || [ ! -d "${prefix}" ]; then
prefix="${HOME}/.local/bin";
echo -e "Creating ziggy python zipfile\n";
sleep 1;
command "${py_ver}" -m zipapp -o ziggy -p "/usr/bin/env python3" -c "${curdir}/pkg";
echo -e "Moving ziggy to ${prefix}";
sleep 1;
mv "${curdir}/ziggy" "${prefix}/ziggy";
else
echo -e "Creating ziggy python zipfile\n";
sleep 1;
command "${py_ver}" -m zipapp -o ziggy -p "/usr/bin/env python3" -c "${curdir}/pkg";
echo -e "Moving ziggy to ${prefix}";
sleep 1;
if [[ $prefix =~ $pattern ]]; then
echo -e "sudo privileges is need to move 'ziggy' to '${prefix}'";
sudo mv "${curdir}/ziggy" "${prefix}/ziggy";
else
mv "${curdir}/ziggy" "${prefix}/ziggy";
fi
fi
}
setup "$@";
ziggy;