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] [Service]
Type=simple Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.sock 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} 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] [Install]
WantedBy=default.target WantedBy=default.target

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