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

Fix ramdisk .init

parent ca6d7d30
#!/bin/sh
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: octavia-agent-certs-ramfs # Provides: octavia-agent-certs-ramfs
# Required-Start: $remote_fs $syslog $network cloud-config # Required-Start: $remote_fs $syslog $network cloud-config
...@@ -12,35 +13,35 @@ ...@@ -12,35 +13,35 @@
# Using the lsb functions to perform the operations. # Using the lsb functions to perform the operations.
. /lib/lsb/init-functions . /lib/lsb/init-functions
# Process name ( For display ) # Process name ( For display )
NAME=certs-ramfs NAME=octavia-agent-certs-ramfs
case $1 in case $1 in
start) start)
log_daemon_msg "Starting the process" "$NAME" log_daemon_msg "Starting Octavia Agent RAMDISK" "$NAME"
modprobe brd 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) 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) certs_path=$(grep base_cert_dir /etc/octavia/amphora-agent.conf | awk '{print $3}')
mkdir -p "${certs_path}" mkdir -p "${certs_path}"
echo -n "${passphrase}" | cryptsetup luksFormat /dev/ram0 - echo -n "${passphrase}" | cryptsetup luksFormat /dev/ram0 -
echo -n "${passphrase}" | cryptsetup luksOpen /dev/ram0 certfs-ramfs - echo -n "${passphrase}" | cryptsetup luksOpen /dev/ram0 certfs-ramfs -
mkfs.ext2 /dev/mapper/certfs-ramfs mkfs.ext2 /dev/mapper/certfs-ramfs
mount /dev/mapper/certfs-ramfs "${certs_path}" mount /dev/mapper/certfs-ramfs "${certs_path}"
log_end_msg 0 log_end_msg 0
;; ;;
stop) stop)
log_daemon_msg "Stopping the process" "$NAME" log_daemon_msg "Stopping Octavia Agent RAMDISK" "$NAME"
certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf) certs_path=$(awk "/base_cert_dir / {printf \$3}" /etc/octavia/amphora-agent.conf)
umount "${certs_path}" umount "${certs_path}"
cryptsetup luksClose /dev/mapper/certfs-ramfs cryptsetup luksClose /dev/mapper/certfs-ramfs
log_end_msg 0 log_end_msg 0
;; ;;
restart) restart|force-reload)
# Restart the daemon. # Restart the daemon.
$0 stop && sleep 2 && $0 start $0 stop && sleep 2 && $0 start
;; ;;
*) *)
# For invalid arguments, print the usage message. # For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|restart|reload|status}" echo "Usage: $0 {start|stop|restart|reload|status}"
exit 2 exit 2
;; ;;
esac 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