Skip to content

Commit

Permalink
[Utils] Uninstall Script Improvement (WasmEdge#947)
Browse files Browse the repository at this point in the history
* [Utils] Uninstall Script: Fix source statement removal

* Suggestions from WasmEdge#946 (comment)
* Creates a backup of shell config incase of misshap with extension .wasmedge_backup
* Added GitHub CI test for the above addition

* [Utils] Uninstall Script: Added source removals for bash_profile and profile

* Also added their corresponding CI tests

Signed-off-by: Shreyas Atre <[email protected]>
  • Loading branch information
SAtacker authored Dec 30, 2021
1 parent 2dd30d9 commit f3018a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/test-install-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ jobs:
- name: Uninstall WasmEdge with Image extensions
run: |
bash utils/uninstall.sh -q -V
- name: Uninstall WasmEdge and Source Line removal check
run: |
bash utils/install.sh && bash utils/uninstall.sh -q
grep -qE *.wasmedge/env* ~/.bashrc && echo "Failed: Source Lines found" || echo "Pass: Source Lines Removed"
grep -qE *.wasmedge/env* ~/.bash_profile && echo "Failed: Source Lines found" || echo "Pass: Source Lines Removed"
grep -qE *.wasmedge/env* ~/.profile && echo "Failed: Source Lines found" || echo "Pass: Source Lines Removed"
macos:
strategy:
Expand Down
19 changes: 18 additions & 1 deletion utils/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ remove_parsed() {
ask_remove "$IPATH"
fi
fi
exit 0
else
echo "${RED}env file not found${NC}"
exit 1
fi
}

Expand Down Expand Up @@ -242,6 +242,23 @@ main() {
fi

detect_bin_path wasmedge

local _shell_ _shell_rc line_num
_shell_="${SHELL#${SHELL%/*}/}"
_shell_rc=".""$_shell_""rc"

line_num="$(grep -n ". \"${IPATH}/env\"" "${__HOME__}/${_shell_rc}" | cut -d : -f 1)"

if [ "$line_num" != "" ]; then
sed -i.wasmedge_backup -e "${line_num}"'d' "${__HOME__}/${_shell_rc}"
[[ -f "${__HOME__}/.profile" ]] && line_num="$(grep -n ". \"${IPATH}/env\"" "${__HOME__}/.profile" | cut -d : -f 1)" &&
sed -i.wasmedge_backup -e "${line_num}"'d' "${__HOME__}/.profile"
[[ -f "${__HOME__}/.bash_profile" ]] && line_num="$(grep -n ". \"${IPATH}/env\"" "${__HOME__}/.bash_profile" | cut -d : -f 1)" &&
sed -i.wasmedge_backup -e "${line_num}"'d' "${__HOME__}/.bash_profile"
else
echo "${YELLOW}Sourcing not found in ${__HOME__}/${_shell_rc} ${NC}"
exit 1
fi
}

main "$@"

0 comments on commit f3018a3

Please sign in to comment.