diff --git a/plugins/code-server/plugin.yaml b/plugins/code-server/plugin.yaml index fd7e5e3..5b8cb77 100644 --- a/plugins/code-server/plugin.yaml +++ b/plugins/code-server/plugin.yaml @@ -16,7 +16,7 @@ permissions: ports: - 8080 # code-server web UI (listens on loopback; reach via tunnel/Tailscale) files: - - /home/ec2-user/.config/code-server/config.yaml + - ~/.config/code-server/config.yaml # in the login user's home config: port: @@ -53,31 +53,40 @@ remote: set -eu PORT={{ config.port }} PASSWORD={{ config.password }} - # code-server reads ~/.config/code-server/config.yaml of the service user. - install -d -o ec2-user -g ec2-user /home/ec2-user/.config/code-server - cat > /home/ec2-user/.config/code-server/config.yaml < systemd template unit). + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$HOME_DIR/.config/code-server" + cat > "$HOME_DIR/.config/code-server/config.yaml" < /etc/systemd/system/jupyterlab.service < /home/ec2-user/.config/rclone/rclone.conf - chown ec2-user:ec2-user /home/ec2-user/.config/rclone/rclone.conf - chmod 600 /home/ec2-user/.config/rclone/rclone.conf + LOGIN_USER={{ instance.login_user }} + HOME_DIR=$(getent passwd "$LOGIN_USER" | cut -d: -f6) + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$HOME_DIR/.config/rclone" + printf '%s' "$CONF" > "$HOME_DIR/.config/rclone/rclone.conf" + chown "$LOGIN_USER:$LOGIN_USER" "$HOME_DIR/.config/rclone/rclone.conf" + chmod 600 "$HOME_DIR/.config/rclone/rclone.conf" - type: run run: | set -eu REMOTE={{ config.remote }} RPATH={{ config.path }} MOUNT_PATH={{ config.mount_path }} - install -d -o ec2-user -g ec2-user "$MOUNT_PATH" + LOGIN_USER={{ instance.login_user }} + HOME_DIR=$(getent passwd "$LOGIN_USER" | cut -d: -f6) + install -d -o "$LOGIN_USER" -g "$LOGIN_USER" "$MOUNT_PATH" # allow_other lets other users see the mount; requires user_allow_other in # /etc/fuse.conf, which we ensure. grep -q '^user_allow_other' /etc/fuse.conf 2>/dev/null || echo user_allow_other >> /etc/fuse.conf @@ -107,8 +111,8 @@ remote: [Service] Type=notify - User=ec2-user - ExecStart=/usr/bin/rclone mount ${REMOTE}:${RPATH} $MOUNT_PATH --config /home/ec2-user/.config/rclone/rclone.conf --allow-other --vfs-cache-mode writes + User=$LOGIN_USER + ExecStart=/usr/bin/rclone mount ${REMOTE}:${RPATH} $MOUNT_PATH --config $HOME_DIR/.config/rclone/rclone.conf --allow-other --vfs-cache-mode writes ExecStop=/bin/fusermount -u $MOUNT_PATH Restart=on-failure diff --git a/plugins/vscode-tunnel/plugin.yaml b/plugins/vscode-tunnel/plugin.yaml index 94362e8..e9f58ba 100644 --- a/plugins/vscode-tunnel/plugin.yaml +++ b/plugins/vscode-tunnel/plugin.yaml @@ -61,10 +61,11 @@ remote: run: | set -eu NAME={{ config.name }} + LOGIN_USER={{ instance.login_user }} NAME_ARG="" [ -n "$NAME" ] && NAME_ARG="--name $NAME" - # Per-user service: runs `code tunnel` as ec2-user so the device-login - # token and tunnel state persist under /home/ec2-user/.vscode-cli. + # Per-user service: runs `code tunnel` as the login user so the + # device-login token + tunnel state persist under that user's ~/.vscode-cli. cat > /etc/systemd/system/vscode-tunnel.service <