Skip to content

Commit

Permalink
fix: improve readability of installation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph0enixKM committed May 10, 2024
1 parent 60f1e2e commit 77e206a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
6 changes: 4 additions & 2 deletions setup/install.ab
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ let agent = has_failed("uname -a")
then "unknown"
else unsafe $uname -a$

echo ""

main {
// Determine OS type
let os_type = $uname -s$ failed {
Expand Down Expand Up @@ -88,6 +90,6 @@ main {
unsafe silent $curl -G --data-urlencode "agent={agent}" --data-urlencode "name=download" "https://amber-lang.com/api/visit"$

// Send success message
unsafe $echo -e "{"\\033[0;32m"}Amber has been installed successfully.{"\\033[0m"} 🎉"$
echo "\nNow you can use amber by typing `amber` in your terminal."
echo "Amber has been installed successfully. 🎉"
echo "> Now you can use amber by typing `amber` in your terminal."
}
54 changes: 25 additions & 29 deletions setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ if [ $__AMBER_STATUS != 0 ]; then
:
fi;
__4_agent=$(if [ ${__AMBER_FUN_has_failed18_v0__7} != 0 ]; then echo "unknown"; else echo "${__AMBER_VAL_0}"; fi);
echo "";

__AMBER_VAL_1=$(uname -s);
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to determine OS type.";
echo "Please try again or use another download method.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__16=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__16} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__18=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__18} > /dev/null 2>&1
fi;
os_type="${__AMBER_VAL_1}";
os=$(if [ $([ "_${os_type}" != "_Darwin" ]; echo $?) != 0 ]; then echo "macos"; else echo "linux"; fi);
Expand All @@ -57,14 +58,14 @@ if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to determine architecture.";
echo "Please try again or use another download method.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__26=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__26} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__28=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__28} > /dev/null 2>&1
fi;
arch_type="${__AMBER_VAL_2}";
__AMBER_ARRAY_0=("arm64" "aarch64");
includes__20_v0 __AMBER_ARRAY_0[@] "${arch_type}";
__AMBER_FUN_includes20_v0__28=${__AMBER_FUN_includes20_v0};
arch=$(if [ ${__AMBER_FUN_includes20_v0__28} != 0 ]; then echo "aarch64"; else echo "x86_64"; fi);
__AMBER_FUN_includes20_v0__30=${__AMBER_FUN_includes20_v0};
arch=$(if [ ${__AMBER_FUN_includes20_v0__30} != 0 ]; then echo "aarch64"; else echo "x86_64"; fi);
url="https://github.com/Ph0enixKM/${__0_name}/releases/download/${__2_tag}/amber_${os}_${arch}";
test -d "${__3_place}"
__AMBER_STATUS=$?;
Expand All @@ -77,17 +78,17 @@ fi;
echo "If you want to reinstall Amber, uninstall it first.";
echo "(Find out more at https://docs.amber-lang.com/getting_started/installation#uninstallation)";
exit__19_v0 2;
__AMBER_FUN_exit19_v0__43=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__43} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__45=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__45} > /dev/null 2>&1
fi;
has_failed__18_v0 "curl -V";
__AMBER_FUN_has_failed18_v0__47=${__AMBER_FUN_has_failed18_v0};
if [ ${__AMBER_FUN_has_failed18_v0__47} != 0 ]; then
__AMBER_FUN_has_failed18_v0__49=${__AMBER_FUN_has_failed18_v0};
if [ ${__AMBER_FUN_has_failed18_v0__49} != 0 ]; then
echo "Curl is not installed on your system.";
echo "Please install \`curl\` and try again.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__50=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__50} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__52=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__52} > /dev/null 2>&1
fi;
echo "Installing Amber... 🚀";
curl -L -o "${__1_target}" "${url}" > /dev/null 2>&1
Expand All @@ -96,54 +97,49 @@ if [ $__AMBER_STATUS != 0 ]; then
echo "Curl failed to download amber.";
echo "Something went wrong. Please try again later.";
exit__19_v0 1 > /dev/null 2>&1;
__AMBER_FUN_exit19_v0__59=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__59} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__61=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__61} > /dev/null 2>&1
fi;
sudo mkdir "${__3_place}" > /dev/null 2>&1
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to create directory for amber.";
echo "Please make sure that root user can access /opt directory.";
exit__19_v0 1 > /dev/null 2>&1;
__AMBER_FUN_exit19_v0__66=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__66} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__68=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__68} > /dev/null 2>&1
fi;
sudo mv "${__1_target}" "${__3_place}/${__1_target}"
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to move amber to the installation directory.";
echo "Please make sure that root user can access /opt directory.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__72=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__72} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__74=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__74} > /dev/null 2>&1
fi;
sudo chmod +x "${__3_place}/${__1_target}"
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to give permissions to execute amber.";
echo "Please make sure that root user can access /opt directory.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__78=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__78} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__80=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__80} > /dev/null 2>&1
fi;
sudo ln -s "${__3_place}/${__1_target}" "/usr/local/bin/${__1_target}"
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to create amber symbol link.";
echo "Please make sure that root user can access /usr/local/bin directory.";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__84=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__84} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__86=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__86} > /dev/null 2>&1
fi;
curl -G --data-urlencode "agent=${__4_agent}" --data-urlencode "name=download" "https://amber-lang.com/api/visit" > /dev/null 2>&1
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
:
fi;
echo -e "\033[0;32mAmber has been installed successfully.\033[0m 🎉"
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
:
fi;
echo "
Now you can use amber by typing \`amber\` in your terminal."
echo "Amber has been installed successfully. 🎉";
echo "> Now you can use amber by typing \`amber\` in your terminal."
2 changes: 2 additions & 0 deletions setup/uninstall.ab
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { exit } from "std"

let place = "/opt/amber"

echo ""

main {
unsafe $test -d "{place}" > /dev/null$

Expand Down
9 changes: 5 additions & 4 deletions setup/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if [ $__AMBER_STATUS != 0 ]; then
fi
}
__0_place="/opt/amber";
echo "";

test -d "${__0_place}" > /dev/null
__AMBER_STATUS=$?;
Expand All @@ -20,17 +21,17 @@ if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to remove Amber from ${__0_place}";
echo "Make sure root has the correct permissions to access this directory";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__12=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__12} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__14=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__14} > /dev/null 2>&1
fi;
sudo rm "/usr/local/bin/amber"
__AMBER_STATUS=$?;
if [ $__AMBER_STATUS != 0 ]; then
echo "Failed to remove Amber from /usr/local/bin";
echo "Make sure root has the correct permissions to access this directory";
exit__19_v0 1;
__AMBER_FUN_exit19_v0__17=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__17} > /dev/null 2>&1
__AMBER_FUN_exit19_v0__19=${__AMBER_FUN_exit19_v0};
echo ${__AMBER_FUN_exit19_v0__19} > /dev/null 2>&1
fi;
echo "Uninstalled Amber successfully 🎉"
else
Expand Down

0 comments on commit 77e206a

Please sign in to comment.