From cffcc10fab0435c24b64b4d9eccbf1a221e72ece Mon Sep 17 00:00:00 2001 From: Jika Date: Mon, 19 Jan 2026 10:02:56 +0100 Subject: [PATCH] Add install script --- .chezmoiignore | 1 + install.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 install.sh diff --git a/.chezmoiignore b/.chezmoiignore index 04de44e..60f82d1 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -1 +1,2 @@ to_install.txt +install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..c2a19d2 --- /dev/null +++ b/install.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# FIXME inline install.sh here instead of using curl | sh +# FIXME consider using packages to install chezmoi on deb and rpm-based systems + +set -e + +cd "${HOME}" + +is_command() { + type "${1}" >/dev/null 2>&1 +} + +if [ -n "${LOGNAME}" ]; then + username="${LOGNAME}" +elif [ -n "${USER}" ]; then + username="${USER}" +elif [ -n "${USERNAME}" ]; then + username="${USERNAME}" +elif is_command whoami; then + username="$(whoami)" +elif is_command logname; then + username="$(logname)" +else + printf "unable to determine username" 1>&2 + exit 1 +fi + +sudo= +if [ "${username}" != "root" ]; then + sudo="sudo " +fi + +chezmoi=chezmoi +if is_command chezmoi; then + chezmoi --version +elif is_command "${HOME}/.local/bin/chezmoi"; then + chezmoi="${HOME}/.local/bin/chezmoi" +elif is_command "${HOME}/bin/chezmoi"; then + chezmoi="${HOME}/bin/chezmoi" +elif is_command curl; then + sh -c "$(curl -fsSL get.chezmoi.io/lb)" + chezmoi="$HOME/.local/bin/chezmoi" +elif is_command wget; then + sh -c "$(wget -qO- get.chezmoi.io/lb)" + chezmoi="$HOME/.local/bin/chezmoi" +else + echo "unable to install chezmoi" 1>&2 + exit 1 +fi + +${chezmoi} init --apply "git@git.jika.li:Jika/dotfiles.git" + +shell="$(awk -F : "\$1 == \"${username}\" { print \$7 }" /etc/passwd)" +exec "${shell}"