Fix install script
This commit is contained in:
46
install.sh
46
install.sh
@@ -11,26 +11,6 @@ set -o nounset
|
|||||||
DOTDIR="/var/lib/dotfiles"
|
DOTDIR="/var/lib/dotfiles"
|
||||||
_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
[[ -e './.git' ]] && git submodule update --init
|
|
||||||
|
|
||||||
if [[ "$(readlink "${_SCRIPT_DIR}")" != "${DOTDIR}" ]] && [[ "${_SCRIPT_DIR}" != "${DOTDIR}" ]] ; then
|
|
||||||
if [[ -e "${DOTDIR}" ]] ; then
|
|
||||||
2>&1 printf "${DOTDIR} already exists. This seems unsafe.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
printf "Moving directory to $DOTDIR ...\n"
|
|
||||||
sudo=""
|
|
||||||
if (( $(id -u ) != 0 )) ; then
|
|
||||||
sudo=sudo
|
|
||||||
fi
|
|
||||||
$sudo mv --no-target-directory "${_SCRIPT_DIR}" "${DOTDIR}"
|
|
||||||
printf "Done\n"
|
|
||||||
else
|
|
||||||
printf "Already working in ${DOTDIR}, nothing to do\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${DOTDIR}"
|
|
||||||
|
|
||||||
os_release_file=/etc/os-release
|
os_release_file=/etc/os-release
|
||||||
if [[ ! -e "${os_release_file}" ]] ; then
|
if [[ ! -e "${os_release_file}" ]] ; then
|
||||||
2>&1 printf "Could not find ${os_release_file}, exiting"
|
2>&1 printf "Could not find ${os_release_file}, exiting"
|
||||||
@@ -51,7 +31,11 @@ cache_updated=0
|
|||||||
_install() {
|
_install() {
|
||||||
_package="$1" ; shift
|
_package="$1" ; shift
|
||||||
if [[ $NAME == "Arch Linux" ]] ; then
|
if [[ $NAME == "Arch Linux" ]] ; then
|
||||||
sudowrap pacman -S --noconfirm "${_package}"
|
if (( ! cache_updated )) ; then
|
||||||
|
sudowrap pacman -Sy
|
||||||
|
cache_updated=1
|
||||||
|
fi
|
||||||
|
sudowrap pacman -S --needed --noconfirm "${_package}"
|
||||||
else
|
else
|
||||||
2>&1 printf "Unsupported distro $NAME, exiting"
|
2>&1 printf "Unsupported distro $NAME, exiting"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -80,4 +64,24 @@ if [[ $NAME == "Arch Linux" ]] ; then
|
|||||||
_install "ansible"
|
_install "ansible"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ -e './.git' ]] && git submodule update --init
|
||||||
|
|
||||||
|
if [[ "$(readlink "${_SCRIPT_DIR}")" != "${DOTDIR}" ]] && [[ "${_SCRIPT_DIR}" != "${DOTDIR}" ]] ; then
|
||||||
|
if [[ -e "${DOTDIR}" ]] ; then
|
||||||
|
2>&1 printf "${DOTDIR} already exists. This seems unsafe.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "Moving directory to $DOTDIR ...\n"
|
||||||
|
sudo=""
|
||||||
|
if (( $(id -u ) != 0 )) ; then
|
||||||
|
sudo=sudo
|
||||||
|
fi
|
||||||
|
$sudo mv --no-target-directory "${_SCRIPT_DIR}" "${DOTDIR}"
|
||||||
|
printf "Done\n"
|
||||||
|
else
|
||||||
|
printf "Already working in ${DOTDIR}, nothing to do\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${DOTDIR}"
|
||||||
|
|
||||||
cd "$DOTDIR" && make
|
cd "$DOTDIR" && make
|
||||||
|
|||||||
Reference in New Issue
Block a user