mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
Merge pull request #130 from felipeconti/master
Installing on /usr/local/bin as root
This commit is contained in:
18
install.sh
18
install.sh
@@ -5,6 +5,10 @@ KERNEL=$(uname -s)
|
|||||||
|
|
||||||
function output() { echo -e "\033[32mctop-install\033[0m $@"; }
|
function output() { echo -e "\033[32mctop-install\033[0m $@"; }
|
||||||
|
|
||||||
|
function command_exists() {
|
||||||
|
command -v "$@" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# extract github download url matching pattern
|
# extract github download url matching pattern
|
||||||
function extract_url() {
|
function extract_url() {
|
||||||
match=$1; shift
|
match=$1; shift
|
||||||
@@ -28,6 +32,18 @@ case $KERNEL in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
sh_c='sh -c'
|
||||||
|
if [ "$CURRENT_USER" != 'root' ]; then
|
||||||
|
if command_exists sudo; then
|
||||||
|
sh_c='sudo -E sh -c'
|
||||||
|
elif command_exists su; then
|
||||||
|
sh_c='su -c'
|
||||||
|
else
|
||||||
|
output "Error: this installer needs the ability to run commands as root. We are unable to find either "sudo" or "su" available to make this happen."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
TMP=$(mktemp -d "${TMPDIR:-/tmp}/ctop.XXXXX")
|
TMP=$(mktemp -d "${TMPDIR:-/tmp}/ctop.XXXXX")
|
||||||
cd ${TMP}
|
cd ${TMP}
|
||||||
|
|
||||||
@@ -55,6 +71,6 @@ wget -q --show-progress $url
|
|||||||
|
|
||||||
output "installing to /usr/local/bin"
|
output "installing to /usr/local/bin"
|
||||||
chmod +x ctop-*
|
chmod +x ctop-*
|
||||||
sudo mv ctop-* /usr/local/bin/ctop
|
$sh_c "mv ctop-* /usr/local/bin/ctop"
|
||||||
|
|
||||||
output "done!"
|
output "done!"
|
||||||
|
|||||||
Reference in New Issue
Block a user