Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update quick-install.sh #215

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions quick-install.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/bash
#!/bin/sh
set -e

apt_fast_installation() {
if ! type aria2c >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y aria2
fi
if [ -n "$EUID" ]; then userid="$EUID"; else userid="$(id -u)"; fi

wget https://raw.githubusercontent.com/ilikenwf/apt-fast/master/apt-fast -O /usr/local/sbin/apt-fast
chmod +x /usr/local/sbin/apt-fast
if ! [[ -f /etc/apt-fast.conf ]]; then
wget https://raw.githubusercontent.com/ilikenwf/apt-fast/master/apt-fast.conf -O /etc/apt-fast.conf
fi
run_cmd() {
[ "$userid" -ne 0 ] && set -- sudo "$@"
"$@"
}
apt_fast_url='https://raw.githubusercontent.com/ilikenwf/apt-fast/master'


if [[ "$EUID" -eq 0 ]]; then
apt_fast_installation
else
if [ "$userid" -ne 0 ]; then
type sudo >/dev/null 2>&1 || { echo "sudo not installed, change into root context" >&2; exit 1; }
fi

if ! type aria2c >/dev/null 2>&1; then
run_cmd apt-get update
run_cmd apt-get install -y aria2
fi

DECL="$(declare -f apt_fast_installation)"
sudo bash -c "$DECL; apt_fast_installation"
run_cmd wget "$apt_fast_url"/apt-fast -O /usr/local/sbin/apt-fast
run_cmd chmod +x /usr/local/sbin/apt-fast
if [ ! -f /etc/apt-fast.conf ]; then
run_cmd wget "$apt_fast_url"/apt-fast.conf -O /etc/apt-fast.conf
fi