---
name: "csp_helper"
section: "1"
platform: "linux"
package: "caspar"
version: "20240818-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/csp_helper"
---

# csp\_helper(1)

csp\_helper - A collection of caspar helper scripts **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*) The scripts **csp\_install**, **csp\_mkdircp**, **csp\_scp\_keep\_mode** and **csp\_sucp** are helpers for **[caspar(7)](/caspar/7.md)**. These scripts typically are not invoked directly, but via a Makefile which uses **caspar**. See the notes on csp\_PUSH in **[caspar(7)](/caspar/7.md)** for information on how to link **csp\_install**, **csp\_scp\_keep\_mode** and **csp\_sucp** to **caspar**. **csp\_install** creates the required directory (if needed) and installs the file, preserving timestamps. It uses [install(1)](/install/1.md).

```
 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
```

```

```

**csp\_install** honors csp\_INSTALL\_OPTIONS and csp\_INSTALL\_MODE (default is u=rw,go=r). **csp\_mkdircp** calls [mkdir(1)](/mkdir/1.md) and [cp(1)](/cp/1.md). **csp\_mkdircp** is used like csp\_CP. use **csp\_mkdircp** if you frequently have to bootstrap installation on a fresh system, on which needed directories don't exist yet. **csp\_mkdircp** makes sure the target directory exists before calling [cp(1)](/cp/1.md), by calling mkdir -p first. **csp\_scp\_keep\_mode** uses ssh to copy a file to a remote host, keeping its file permission mode. The trick used is a combination of [mktemp(1)](/mktemp/1.md) and [mv(1)](/mv/1.md). Useful if you'd like to be sure a file gets installed e.g. group writable, without fiddling with permission bits on the remote host.

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

```

```

**csp\_scp\_keep\_mode** honors csp\_SSH ("ssh" by default). **csp\_sucp** calls [tar(1)](/tar/1.md) from within sudo(1) from within [ssh(1)](/ssh/1.md). This allows one to copy files to accounts on hosts one can only reach by calling sudo on the ssh-reachable remote host.

Typically, one wants to install a root-owned file, but one does not want to allow access to the root-account directly from ssh. Typically sudo is used as an extra line of defense.

NB: if your sudo prompts for a password, be sure to have line

```
  Defaults !tty_tickets
```

```

```

in your sudoers file: we first call sudo -v, than we call sudo to write the data. Since we use ssh to get to the host, we'll use a different tty for both sudo calls. Some examples:

```
  csp_sucp rms@bilbo /etc fstab
```

```

```

```
  csp_sucp monty-python commit/ trailer.txt
```

```

```

Joost van Baal-Ilić **[caspar(7)](/caspar/7.md)** The caspar homepage is at http://mdcc.cx/caspar/ .
