Update 'install.sh'
This commit is contained in:
16
install.sh
16
install.sh
@@ -18,7 +18,8 @@ while getopts "h?vyi:acrbm:p" opt; do
|
||||
b) P_BINARY=1 ;;
|
||||
i) P_Install=$OPTARG ;;
|
||||
m) ARCH=$OPTARG ;;
|
||||
a) P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1 ;;
|
||||
z) P_ZSH=1 ;;
|
||||
a) P_APT=1; P_DEB=1; P_CONFIG=1; P_RC=1; P_BINARY=1; P_ZSH=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -83,7 +84,7 @@ function user_confirm_overwrite {
|
||||
}
|
||||
|
||||
function download_config {
|
||||
if [ ! -z "$P_CONFIG" ]; then return 0; fi
|
||||
if [ -z "$P_CONFIG" ]; then return 0; fi
|
||||
mkdir -p "$CONFIG_PATH/$1/"
|
||||
FILE="$CONFIG_PATH/$1/$2"
|
||||
if [ ! -e "$FILE" ] || user_confirm_overwrite "$FILE"; then
|
||||
@@ -93,7 +94,7 @@ function download_config {
|
||||
}
|
||||
|
||||
function install_rc {
|
||||
if [ ! -z "$P_RC" ]; then return 0; fi
|
||||
if [ -z "$P_RC" ]; then return 0; fi
|
||||
# Make sure the directory exists
|
||||
mkdir -p "$CONFIG_PATH/$1/"
|
||||
|
||||
@@ -128,7 +129,7 @@ function install_rc {
|
||||
}
|
||||
|
||||
function init_install_rc {
|
||||
if [ ! -z "$P_RC" ]; then return 0; fi
|
||||
if [ -z "$P_RC" ]; then return 0; fi
|
||||
# Add the file to the rc file as source $file
|
||||
SOURCE_CMD="$1"
|
||||
RC="$HOME_PATH/$RC_FILE"
|
||||
@@ -172,7 +173,7 @@ function install_deb_check {
|
||||
}
|
||||
|
||||
function install_deb {
|
||||
if [ ! -z "$P_DEB" ]; then return 0; fi
|
||||
if [ -z "$P_DEB" ]; then return 0; fi
|
||||
log_info "Downloading $2 to $TMP_PATH ..."
|
||||
wget -O $TMP_PATH/$1.deb $2 > /dev/null 2>&1
|
||||
|
||||
@@ -202,8 +203,10 @@ function init {
|
||||
log_info "Exiting ..."
|
||||
exit 0
|
||||
fi
|
||||
if [ ! -z "$P_APT" ]; then
|
||||
log_info "Running apt update ..."
|
||||
sudo apt update > /dev/null 2>&1
|
||||
fi
|
||||
mkdir -p $TMP_PATH/
|
||||
mkdir -p $CONFIG_PATH/
|
||||
}
|
||||
@@ -213,7 +216,7 @@ function cleanup {
|
||||
}
|
||||
|
||||
function apt_install {
|
||||
if [ ! -z "$P_APT" ]; then return 0; fi
|
||||
if [ -z "$P_APT" ]; then return 0; fi
|
||||
RESULT=$(sudo apt install -y $1 2>&1 )
|
||||
if echo "$1 is already the newest version" | grep "$RESULT" > /dev/null; then
|
||||
log_info "$1 is already installed"
|
||||
@@ -267,6 +270,7 @@ function install_binary_github {
|
||||
}
|
||||
|
||||
function set_shell {
|
||||
if [ -z "$P_ZSH" ]; then return 0; fi
|
||||
CURR_U=$(grep "^$USER" /etc/passwd | cut -d ':' -f 7 | cut -d '/' -f 4)
|
||||
CURR_R=$(grep "^root" /etc/passwd | cut -d ':' -f 7 | cut -d '/' -f 4)
|
||||
if [[ $1 != $CURR_U ]]; then
|
||||
|
||||
Reference in New Issue
Block a user