| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
cryptsetup_args="--type=luks1" |
| 4 |
|
| 5 |
# Only 1 block ram device is needed |
| 6 |
modprobe brd rd_nr=1 |
| 7 |
|
| 8 |
passphrase=$(head /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 32 | head -n 1) |
| 9 |
certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf) |
| 10 |
mkdir -p "${certs_path}" |
| 11 |
|
| 12 |
echo -n "${passphrase}" | cryptsetup $cryptsetup_args luksFormat /dev/ram0 - |
| 13 |
echo -n "${passphrase}" | cryptsetup $cryptsetup_args luksOpen /dev/ram0 certfs-ramfs - |
| 14 |
|
| 15 |
mkfs.ext2 /dev/mapper/certfs-ramfs |
| 16 |
mount /dev/mapper/certfs-ramfs "${certs_path}" |