-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_mono.sh
executable file
·37 lines (31 loc) · 1.31 KB
/
install_mono.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 sh
command_name="citelink"
install_folder="/usr/local/bin/cite_link_changer"
# make sure script is run as sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# make sure mono is installed. If not, display a warning message
# to install it.
if ! [ -x "$(command -v mono)" ]; then
echo 'Warning: mono is not installed.' >&2
echo 'The citelink install will continue, but please install mono before using the script!' >&2
fi
# make target directory if it doesn't exist
if [ ! -d "$install_folder" ]; then
mkdir -p "$install_folder"
fi
# Copy the contents of ./cite_link_changer_mono into an installation folder
sudo cp -r ./cite_link_changer_mono/* "$install_folder"
# if command already exists, then we only want to update files
# Check if the command exists and exit if it does
if command -v "$command_name" >/dev/null 2>&1; then
echo "$command_name command found, update complete!"
exit
fi
# Create the command-line command "citelink" that runs "mono /path/to/install/cite_link_changer.exe" with the given argument afterwards.
echo "#!/usr/bin/env sh" | sudo tee "/usr/local/bin/$command_name" > /dev/null
echo "mono $install_folder/cite_link_changer.exe \"\$@\"" | sudo tee -a "/usr/local/bin/$command_name" > /dev/null
# Make it executable
sudo chmod +x "/usr/local/bin/$command_name"