-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·55 lines (43 loc) · 1.84 KB
/
install.sh
File metadata and controls
executable file
·55 lines (43 loc) · 1.84 KB
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
#!/bin/bash
echo -e "Installation script for aliasrc executed!"
newest_version=$(curl "https://raw.githubusercontent.com/NiroUwU/aliasrc/main/aliasrc") || (echo -e "Failed to fetch newest version" && return)
install_path=~/aliasrc
# Check for conflicting files:
if [[ -f $install_path ]]; then
echo -e "'$install_path' already exists, what to do?"
echo -e "1) Continue anyways (may delete data)"
echo -e "2) Change installation path"
echo -e "3) Abort installation"
printf "Please type an integer >> " && read inp
case $inp in
1)
echo -e "Continueing install"
;;
2)
printf "Please input a new, full installation path >> " && read install_path
# Check validity of new destination:
if [[ -f "$install_path" || -d "$install_path" ]]; then
echo -e "Cannot write file '$install_path', either an already existing file or a directory. Aborting." && exit
fi
;;
3)
echo -e "Installation aborted." && exit
;;
*)
echo -e "Invalid option, aborting installation." && exit
esac
fi
# Write data to file:
echo -e "Installing in aliasrc to '$install_path'"
(echo "$newest_version" > "$install_path" && echo -e "Successfully installed aliasrc to '$install_path'!") || (echo -e "Install unsuccessful. Aborting!"; exit)
# Check for writing validity:
if [[ ! $(cat "$install_path") == "$newest_version" ]]; then
echo -e "Data was not written or written data was corrupted. Aborting." && exit
fi
# Delete Installation script if data successfully written:
if [[ $(cat "$install_path") == "$newest_version" ]]; then
(rm "$0" && echo -e "Removed installation script.") || echo -e "Failed to remove installation script."
fi
# Post-Install:
COL="\e[32m"
echo -e "\n!!! To finish the install, you will need to add aliasrc to your shell rc file.\nYou can do that by executing:\n'$COL echo \"source $install_path\" >> YOUR_SHELL_RC_FILE_HERE\\e[0m '"