csp_helper(1)

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

πŸ’– csp_helper β€” a whole lil fam of caspar helper scripts πŸ’–

okay bestie, welcome to csp_helper(1), a USER COMMANDS moment. this is the group chat of scripts that make caspar(7) deployments go absolutely off. no cap.


✨ NAME ✨

csp_helper β€” a collection of caspar helper scripts πŸŽ€


🌸 SYNOPSIS 🌸


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 πŸ¦‹

so the squad is csp_install, csp_mkdircp, csp_scp_keep_mode and csp_sucp β€” they're all helpers for caspar(7). and like, these scripts are not the type to show up to the party uninvited: they typically aren't invoked directly, they get pulled in via a Makefile that uses caspar. 🫢

wanna know how to link csp_install, csp_scp_keep_mode and csp_sucp to caspar? go read the notes on csp_PUSH in caspar(7). that's where the lore lives. πŸ’…


🧚 install DESCRIPTION 🧚

csp_install makes the required directory (only if it's needed, obvi) and installs the file, preserving timestamps β€” the timestamps stay untouched, periodt. it does all this by using install(1). iconic behaviour honestly. ✨


πŸ“ install EXAMPLES πŸ“

 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_OPTIONS β€” csp_install honors this one 🫑
  • csp_INSTALL_MODE β€” csp_install honors this one too, and the default is u=rw,go=r ✨

🌈 mkdircp DESCRIPTION 🌈

csp_mkdircp calls mkdir(1) and cp(1). you use it exactly like csp_CP. πŸ“‹

lowkey the moment for csp_mkdircp is when you keep having to bootstrap installation on a fresh system where the directories you need just... don't exist yet. πŸ™ˆ csp_mkdircp makes sure the target directory exists before it calls cp(1), by calling mkdir -p first. so organized. so thoughtful. main character energy fr fr. πŸ‘‘


πŸŽ€ scp_keep_mode DESCRIPTION πŸŽ€

csp_scp_keep_mode uses ssh to copy a file over to a remote host, keeping its file permission mode β€” yes, the mode survives the trip, that's the whole point. πŸ’…

the trick it pulls is a combination of mktemp(1) and mv(1). and bestie, it's so useful if you want to be sure a file gets installed e.g. group writable, without you sitting there fiddling with permission bits on the remote host. not me doing remote chmod gymnastics β€” couldn't be me. 😭


⭐ scp_keep_mode EXAMPLE ⭐

csp_scp_keep_mode root@gandalf /etc/uruk rc

πŸ’– scp_keep_mode ENVIRONMENT πŸ’–

  • csp_SSH β€” csp_scp_keep_mode honors this one, and it's "ssh" by default 🫢

πŸ”₯ sucp DESCRIPTION πŸ”₯

csp_sucp calls tar(1) from within sudo(1) from within ssh(1). yes, three layers deep, it's giving inception. πŸŒ€ this lets you copy files to accounts on hosts you can only reach by calling sudo on the ssh-reachable remote host.

typically you wanna install a root-owned file, but you do not wanna allow access to the root account directly from ssh. so typically sudo gets used as an extra line of defense. πŸ›‘οΈ

NB: if your sudo prompts for a password, be sure to have the line
in your sudoers file β€” because we first call sudo -v, then we call sudo to write the data. and since we use ssh to get to the host, we'll end up using a different tty for both sudo calls. so yeah, don't skip that line, bestie. πŸ’€

🌸 sucp EXAMPLES 🌸

some examples for u:


csp_sucp monty-python commit/ trailer.txt

πŸ‘‘ AUTHOR πŸ‘‘

Joost van Baal-Ilić


🫢 SEE ALSO 🫢


and that's the whole page, bestie!! ✨ this was csp_helper from csp_helper 20220907, dated 7 сСп 2022, hanging out in section 1 of your friendly neighbourhood manual. go forth and install things. slay. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from