systemd: Revamp systemd unit installation

Shipping the wanted symlinks didn't seem to work right and probably
isn't the right approach either. Instead, call into systemctl from
install.extra

May have to manually delete old wanted links and re-run install
master
Taeyeon Mori 7 years ago
parent 8fc06ca351
commit 1b78d7734d
  1. 1
      config/systemd/user/default.target.wants/ssh-agent.service
  2. 4
      config/systemd/user/ssh-agent.service
  3. 26
      install
  4. 5
      install.extra

@ -4,9 +4,9 @@ Description=SSH publickey authentication agent
[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.sock
ExecStart=/usr/bin/ssh-agent -D -a ${SSH_AUTH_SOCK}
ExecStart=/usr/bin/ssh-agent -D -a ${SSH_AUTH_SOCK} -t 2h
ExecStartPost=/usr/bin/systemctl --user set-environment SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
ExecStopPre=/usr/bin/systemctl --user unset-environment SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
ExecStopPost=/usr/bin/systemctl --user unset-environment SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
[Install]
WantedBy=default.target

@ -1,6 +1,6 @@
#!/bin/zsh
# .files/installer
# (c) 2014 MORI Taeyeon
# .files/install
# (c) 2014-2017 MORI Taeyeon
# Paths & Utils
DOT="$(realpath "$(dirname "$0")")"
@ -9,7 +9,9 @@ cd "$DOT"
setopt EXTENDED_GLOB
source "$DOT/lib/libzsh-utils.zsh"
# Parse commandline
# =============================
OVERWRITE=false
ASK=true
@ -41,7 +43,9 @@ for arg in "$@"; do
done
[[ -n "$STATE" ]] && err "Option $STATE is missing it's parameter!" && exit 1
# Helper functions
# =============================
function generate() {
[[ -e "$1" ]] && ! $OVERWRITE && ! grep -q "Generated by .files/install" "$1" && \
err "Custom version of $1 detected. Please delete it before running .files/install" && exit 1
@ -58,6 +62,9 @@ function relink() {
color 31 ln -s "$(relpath "$1" "$(dirname "$2")")" "$2"
}
# Prepare
# =============================
# Update git modules
msg "Updating git submodules..."
git submodule update --init --recursive
@ -77,12 +84,16 @@ else
color 36 echo " default EMAIL=\"$EMAIL\""
fi
# Write down answers
color 32 echo " Writing etc/user-info"
generate "$DOT/etc/user-info" <<EOF
REALNAME="$REALNAME"
EMAIL="$EMAIL"
EOF
# Write files to $HOME
# =============================
# Setup dotfiles
msg "Linking dotfiles..."
for file in "$DOT/dotfiles"/*; do
@ -113,7 +124,9 @@ msg "Linking .config files... ($XDG_CONFIG_HOME)"
done
)
# Setup git
# =============================
msg "Setting up Git configuration..."
GIT="$DOT/git"
@ -138,7 +151,9 @@ generate "$GIT/user-info" <<EOF
email = $EMAIL
EOF
# Setup ZSH/Prezto
# =============================
msg "Setting up ZSH configuration..."
ZSH="$DOT/zsh"
@ -154,7 +169,10 @@ for file in zshrc zpreztorc zlogin zlogout zprofile; do
relink "$ZSH/$file" "$ZSH/.$file"
done
relink "$ZSH/prezto" "$ZSH/.zprezto"
# Do misc setup
# =============================
test -f "$DOTFILES/install.extra" && "$DOTFILES/install.extra"
# Check login shell
if getent passwd $(id -un) | grep -q 'zsh$'; then
@ -164,7 +182,7 @@ else
chsh -s "$(which zsh)"
fi
# Done.
warn "You may need to relog for all changes to take effect."
warn "If you're currently running zsh, you definitely need to at least restart the shell to apply changes."

@ -0,0 +1,5 @@
#!/bin/sh
echo Starting systemd user units
systemctl --user enable --now ssh-agent
Loading…
Cancel
Save