csp_helper(1)

πŸ“¦
this version Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’… NAME πŸ’…

csp_helper β€” a lil collection of caspar helper scripts. bestie, it's a whole toolbox 🧰✨


🌸 SYNOPSIS 🌸

csp_install dir (directory) file (file)

csp_mkdircp dir (directory) file (file)

csp_scp_keep_mode h ([user@]host) dir (directory) file (file)

csp_sucp h ([user@]host) dir (directory) file (file)

🫢 DESCRIPTION 🫢

okay so listen. The scripts csp_install, csp_mkdircp, csp_scp_keep_mode and csp_sucp are helpers for caspar(7). They're not really the kind of thing you call with your own two hands β€” most of the time they get invoked by a Makefile that's using caspar. If you wanna know how to hook csp_install, csp_scp_keep_mode and csp_sucp up to caspar, go read the notes on csp_PUSH in caspar(7). iykyk πŸ’–


πŸ›  install DESCRIPTION πŸ› 

csp_install makes the directory you need (only if it's not there already, no drama) and then installs the file, preserving timestamps. Under the hood it's using install(1). periodt.

✨ install EXAMPLES ✨

 csp_INSTALL_OPTIONS='--owner=www-data --group=www-data' \
  csp_INSTALL_MODE=ugo=r \
  csp_install /srv/www index.html

 csp_INSTALL_MODE=u=rwx,go= csp_install /usr/local/sbin mkpasswd

🌈 install ENVIRONMENT 🌈

csp_install is obsessed with two env vars: csp_INSTALL_OPTIONS and csp_INSTALL_MODE. and if you don't tell it otherwise, the default mode is u=rw,go=r. so generous of it πŸ’œ


πŸ“ mkdircp DESCRIPTION πŸ“

csp_mkdircp calls mkdir(1) and cp(1). You use it the same way you'd use csp_CP. Reach for csp_mkdircp when you keep having to bootstrap an install on a fresh system where the directories you need just… don't exist yet 😭. csp_mkdircp makes sure the target directory is actually there before it calls cp(1), by running mkdir -p first. no cap, it just handles it for you 🫢


πŸ¦‹ scp_keep_mode DESCRIPTION πŸ¦‹

csp_scp_keep_mode uses ssh to copy a file over to a remote host, and it keeps the file's permission mode. The lil trick it pulls off is a combo of mktemp(1) and mv(1). Super handy if you want to be sure a file lands installed, like, group writable, without sitting there fiddling with permission bits on the remote host. iconic behaviour, honestly πŸ‘‘

🌸 scp_keep_mode EXAMPLE 🌸

  chmod g+w rc
  csp_scp_keep_mode root@gandalf /etc/uruk rc

πŸ’« scp_keep_mode ENVIRONMENT πŸ’«

csp_scp_keep_mode honors csp_SSH β€” and if you don't set it, it just defaults to "ssh". easy πŸ’…


πŸ”₯ sucp DESCRIPTION πŸ”₯

csp_sucp calls tar(1) from within sudo(1) from within ssh(1). The way that works out is: it lets you copy files to accounts on hosts you can only reach by calling sudo on the ssh-reachable remote host. so many layers, so much main character energy 🧚

Typically you're trying to install a root-owned file, but you do not want to just open up the root account to ssh directly. So usually sudo gets used as an extra line of defense. smart, honestly.

⚠️ NB: if your sudo prompts you for a password, bestie you GOTTA have this line in your sudoers file:
  Defaults !tty_tickets

Here's why: it first calls sudo -v, and then it calls sudo again to write the data. Since we're using ssh to get to the host, we end up on a different tty for both of those sudo calls. so yeah, that line is not optional πŸ™ˆ

⭐ sucp EXAMPLES ⭐

Some examples:

  csp_sucp rms@bilbo /etc fstab

  csp_sucp monty-python commit/ trailer.txt

πŸ‘‘ AUTHOR πŸ‘‘

Joost van Baal-Ilić


πŸŽ€ SEE ALSO πŸŽ€

caspar(7) β€” and heads up, the caspar homepage lives at http://mdcc.cx/caspar/ . go check it out πŸ¦‹


okay bestie that's the whole page πŸ’– this was csp_helper, version 20220907, dated 7 сСп 2022, and it comes to you from the USER COMMANDS section of the manual. mwah, go install something cute πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from