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