-
Notifications
You must be signed in to change notification settings - Fork 14
/
INSTALL
executable file
·73 lines (60 loc) · 2.6 KB
/
INSTALL
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
#!/bin/bash
echo -e "\nWill install Pyrite application files to /usr/share/pyrite/"
echo "Enter to accept; otherwise enter a different dir, e.g., /home/$USER/.local/share/pyrite/"
read -p "[/usr/share/pyrite]: " install_dir
[[ -z $install_dir ]] && install_dir=/usr/share/pyrite || install_dir=${install_dir%/}
if [[ -d $install_dir ]]; then
echo "Directory '$install_dir' already exists."
echo "All files in directory will be deleted prior to copying new pyrite files."
read -p "Continue? [y/n] "
[[ $REPLY != y ]] && exit
else
if ! mkdir -vp "$install_dir"; then
echo "Could not create directory '$install_dir'"
if [[ ! -w ${install_dir%/*} ]]; then
echo "Need write permission to mkdir in '${install_dir%/*}'"
echo "Re-run this script as root, i.e., 'sudo $0' or 'su -c $0'"
fi
exit 1
fi
fi
echo OK
echo -e "\nWill install a shortcut ('pyrite') to /usr/bin/"
echo "Press Enter to accept; otherwise enter a different dir, e.g., /home/$USER/bin/"
read -p "[/usr/bin/]: " bin_dir
[[ -z $bin_dir ]] && bin_dir=/usr/bin
if [[ ! -w $bin_dir ]]; then
echo "Need write permission to create shortcut in '$bin_dir'"
echo "Re-run this script as root, i.e., 'sudo $0' or 'su -c $0'"
exit 2
fi
echo OK
echo -e "\nWill install a desktop shortcut ('pyrite.desktop') to /usr/share/applications/"
echo "Press Enter to accept; otherwise enter a different dir, e.g., /home/$USER/.local/share/applications/"
read -p "[/usr/share/applications/]: " shortcut_dir
[[ -z $shortcut_dir ]] && shortcut_dir=/usr/share/applications
if [[ ! -w $shortcut_dir ]]; then
echo "Need write permission to create desktop shortcut in '$shortcut_dir'"
echo "Re-run this script as root, i.e., 'sudo $0' or 'su -c $0'"
exit 3
fi
echo OK
echo -e "\nReady to copy files. Last chance to cancel with Ctrl-c. Enter to continue."
read -p ": "
# Remove contents of install dir (usually /usr/share/pyrite/)
rm -r "$install_dir"/* 2>/dev/null
# Copy files to install dir
cp -rv --preserve=mode,timestamps modules ui pyrite.py "$install_dir"
# Modify assetdir variable in cfg.py to point to the proper install dir
sed -i "/^ASSETDIR/s,'.*','$install_dir/'," "$install_dir/modules/cfg.py"
# Copy desktop shortcut
cp -v --preserve=mode,timestamps pyrite.desktop "$shortcut_dir"
# Setup cmdline shortcut
echo -e "\nCreating shortcut $bin_dir/pyrite: "
cat >$bin_dir/pyrite <<EOF
#!/bin/bash
exec python $install_dir/pyrite.py "$@"
EOF
chmod -v +x $bin_dir/pyrite
echo OK
echo -e "\nFinished!\nRun Pyrite from a terminal as simply 'pyrite', or find the desktop shortcut in your applications menu."