mirror of
https://github.com/RyanGreenup/cadmus.git
synced 2025-08-06 22:26:33 +02:00
Fixed Install Script
This commit is contained in:
72
install.sh
72
install.sh
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
INSTALL_DIR="$HOME/.cadmus"
|
INSTALL_DIR="$HOME/.cadmus"
|
||||||
|
BIN_DIR="$HOME/.local/bin/"
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
me=`basename "$0"`
|
me=`basename "$0"`
|
||||||
@@ -11,6 +12,8 @@ main () {
|
|||||||
Install_bin
|
Install_bin
|
||||||
check_path
|
check_path
|
||||||
check_for_dependencies
|
check_for_dependencies
|
||||||
|
|
||||||
|
echo -e "\nInstallation Complete \n"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_path () {
|
check_path () {
|
||||||
@@ -31,7 +34,7 @@ function UninstallQ() {
|
|||||||
HelpStatement() {
|
HelpStatement() {
|
||||||
|
|
||||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
||||||
echo -e "To uninstall do `basename $0` --rm is the script name,
|
echo -e "To uninstall do `basename $0` --rm ,
|
||||||
|
|
||||||
If you are on Arch stow 2.3.1-2 is broken, downgrade with
|
If you are on Arch stow 2.3.1-2 is broken, downgrade with
|
||||||
|
|
||||||
@@ -60,7 +63,7 @@ printThis () {
|
|||||||
safePrint $me
|
safePrint $me
|
||||||
|
|
||||||
|
|
||||||
echo "Are you happy to proceed? Press y to continue"
|
echo -e "\nAre you happy to proceed? Press y to continue \n"
|
||||||
read -d '' -s -n1 proceedQ
|
read -d '' -s -n1 proceedQ
|
||||||
if [ "$proceedQ" != "y" ]; then
|
if [ "$proceedQ" != "y" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
@@ -78,8 +81,6 @@ safePrint () {
|
|||||||
|
|
||||||
check_for_dependencies () {
|
check_for_dependencies () {
|
||||||
|
|
||||||
echo "Missing dependencies will now be printed to STDERR, missing packages to STDOUT"
|
|
||||||
|
|
||||||
## echo "Press Any Key to Check for dependencies, press the c Key to Skip this"
|
## echo "Press Any Key to Check for dependencies, press the c Key to Skip this"
|
||||||
## read -d '' -s -n1 CheckDepQ
|
## read -d '' -s -n1 CheckDepQ
|
||||||
## if [ "$CheckDepQ" == "c" ]; then
|
## if [ "$CheckDepQ" == "c" ]; then
|
||||||
@@ -89,43 +90,58 @@ check_for_dependencies () {
|
|||||||
depLog="$(mktemp)"
|
depLog="$(mktemp)"
|
||||||
|
|
||||||
for i in ${StringArray[@]}; do
|
for i in ${StringArray[@]}; do
|
||||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; echo $i >> "${depLog}"; }
|
command -v "$i" >/dev/null 2>&1 || { echo $i >> "${depLog}"; }
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $(cat "${depLog}") == "" ]]; then
|
if [[ $(cat "${depLog}") == "" ]]; then
|
||||||
echo "All Dependencies Satisfied"
|
echo -e "\nAll Dependencies Satisfied\n"
|
||||||
else
|
else
|
||||||
cat "${depLog}"
|
echo -e "\e[1;31m \nMissing the Following Dependencies \e[0m \n"
|
||||||
|
echo -e " \e[1;31m -------------------------\e[0m "
|
||||||
|
echo -e "\e[1;32m \n"
|
||||||
|
addBullets "$(cat "${depLog}")"
|
||||||
|
echo -e "\e[0m \n"
|
||||||
|
echo -e "They are listed in \e[1;34m "${depLog}" \e[0m \n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addBullets() {
|
||||||
|
command -v sed >/dev/null 2>&1 || { echo >&2 "I require sed but it's not installed. Aborting."; exit 1; }
|
||||||
|
echo "$1" | sed 's/^/\t‣\ /g'
|
||||||
|
}
|
||||||
|
|
||||||
download_the_repo () {
|
download_the_repo () {
|
||||||
|
|
||||||
echo "Press y to download the repo"
|
if [[ -d "${INSTALL_DIR}" ]]; then
|
||||||
read -d '' -s -n1 downloadQ
|
echo -e "Detected a cadmus install"
|
||||||
if [ "$downloadQ" != "y" ]; then
|
|
||||||
|
if [ -f "${INSTALL_DIR}/config.json" ]; then
|
||||||
|
oldConfigFile="$(mktemp)" && cat "${INSTALL_DIR}/config.json" > "${oldConfigFile}"
|
||||||
|
echo -e "\n\tConfig File Backed up for later restore\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ask_to_remove
|
||||||
|
download_the_repo
|
||||||
return
|
return
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d "${INSTALL_DIR}/.git" ]]; then
|
|
||||||
echo "Detected a cadmus install"
|
|
||||||
ask_to_remove
|
|
||||||
elif [[ -f ".git" ]]; then
|
|
||||||
echo "You have a file called .git In "${INSTALL_DIR}", which was unexpected"
|
|
||||||
ask_to_remove
|
|
||||||
else
|
else
|
||||||
git clone https://github.com/RyanGreenup/cadmus "~/.cadmus"
|
git clone https://github.com/RyanGreenup/cadmus "$HOME/.cadmus"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Repository is downloaded"
|
echo -e "Repository is downloaded\n\n"
|
||||||
|
|
||||||
|
if [[ "$CheckDepQ" == "y" ]] && [[ -f "${oldConfigFile}" ]]; then
|
||||||
|
echo -e "Press y to restore the old config or any other key to continue otherwise\n"
|
||||||
|
read -d '' -s -n1 CheckDepQ
|
||||||
|
cp "${oldConfigFile}" "${INSTALL_DIR}/config.json"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ask_to_remove () {
|
ask_to_remove () {
|
||||||
echo "press y to remove "${INSTALL_DIR}""
|
echo "press y to remove "${INSTALL_DIR}""
|
||||||
|
|
||||||
read -d '' -s -n1 CheckDepQ
|
read -d '' -s -n1 CheckDepQ
|
||||||
if [ "$CheckDepQ" != "y" ]; then
|
if [ "$CheckDepQ" == "y" ]; then
|
||||||
rm -rf "${INSTALL_DIR}"
|
rm -rf "${INSTALL_DIR}"
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
@@ -133,7 +149,18 @@ ask_to_remove () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Install_bin() {
|
Install_bin() {
|
||||||
ln -s "$HOME/.cadmus/bin/cadmus" "$HOME/.local/bin/"
|
if [ -f "${BIN_DIR}/cadmus" ]; then
|
||||||
|
echo -e "The executable \e[1;32m "${BIN_DIR}"/cadmus \e[0m already exists, it must be replaced, press y to continue or any key to exit"
|
||||||
|
read -d '' -s -n1 CheckDepQ
|
||||||
|
if [ "$CheckDepQ" == "y" ]; then
|
||||||
|
rm "${BIN_DIR}/cadmus"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Install_bin
|
||||||
|
else
|
||||||
|
ln -s "$HOME/.cadmus/bin/cadmus" "$HOME/.local/bin/" && echo -e "\nSuccessfully created symlink from $HOME/.cadmus/bin/cadmus to $HOME/.local/bin/ \n"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Declare an array of string with type
|
# Declare an array of string with type
|
||||||
@@ -146,6 +173,7 @@ declare -a StringArray=(
|
|||||||
"sk"
|
"sk"
|
||||||
"rg"
|
"rg"
|
||||||
"perl"
|
"perl"
|
||||||
|
"tectonic"
|
||||||
"stow"
|
"stow"
|
||||||
"python"
|
"python"
|
||||||
"tmsu"
|
"tmsu"
|
||||||
|
Reference in New Issue
Block a user