Commit 370e3388 authored by Thomas Goirand's avatar Thomas Goirand

Fix ramdisk .init

parent ca6d7d30
#!/bin/sh
### BEGIN INIT INFO
# Provides: octavia-agent-certs-ramfs
# Required-Start: $remote_fs $syslog $network cloud-config
......@@ -12,35 +13,35 @@
# Using the lsb functions to perform the operations.
. /lib/lsb/init-functions
# Process name ( For display )
NAME=certs-ramfs
NAME=octavia-agent-certs-ramfs
case $1 in
start)
log_daemon_msg "Starting the process" "$NAME"
modprobe brd
passphrase=$(head /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 32 | head -n 1)
certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf)
mkdir -p "${certs_path}"
echo -n "${passphrase}" | cryptsetup luksFormat /dev/ram0 -
echo -n "${passphrase}" | cryptsetup luksOpen /dev/ram0 certfs-ramfs -
mkfs.ext2 /dev/mapper/certfs-ramfs
mount /dev/mapper/certfs-ramfs "${certs_path}"
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping the process" "$NAME"
certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf)
umount "${certs_path}"
cryptsetup luksClose /dev/mapper/certfs-ramfs
log_end_msg 0
;;
restart)
# Restart the daemon.
$0 stop && sleep 2 && $0 start
;;
*)
# For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 2
;;
start)
log_daemon_msg "Starting Octavia Agent RAMDISK" "$NAME"
modprobe brd rd_size=1024000 max_part=2 rd_nr=1
passphrase=$(head /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w 32 | head -n 1)
certs_path=$(grep base_cert_dir /etc/octavia/amphora-agent.conf | awk '{print $3}')
mkdir -p "${certs_path}"
echo -n "${passphrase}" | cryptsetup luksFormat /dev/ram0 -
echo -n "${passphrase}" | cryptsetup luksOpen /dev/ram0 certfs-ramfs -
mkfs.ext2 /dev/mapper/certfs-ramfs
mount /dev/mapper/certfs-ramfs "${certs_path}"
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping Octavia Agent RAMDISK" "$NAME"
certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf)
umount "${certs_path}"
cryptsetup luksClose /dev/mapper/certfs-ramfs
log_end_msg 0
;;
restart|force-reload)
# Restart the daemon.
$0 stop && sleep 2 && $0 start
;;
*)
# For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 2
;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment