Improve encfs cookbook
Fix some things, and prepare for path-based activation. Also, comment the buggy initial dir creation and explain manual provisioning in README for now.
This commit is contained in:
parent
8918452fc5
commit
353f2c13f1
@ -1,3 +1,15 @@
|
||||
# kosmos_encfs
|
||||
|
||||
Install encfs and set up encryption for a data directory
|
||||
Install encfs and set up encryption for a data directory.
|
||||
|
||||
## Provisioning a new machine
|
||||
|
||||
Add encfs to the run list and run chef before adding other cookbooks that
|
||||
depends on the encfs mount.
|
||||
|
||||
Log into the system and create the data directory like so:
|
||||
|
||||
encfs /usr/local/lib/encrypted_data /mnt/data --public
|
||||
|
||||
When asked for config options, choose nothing (i.e. "standard"). Do NOT choose
|
||||
paranoia mode, as it breaks some software, like e.g. PostgreSQL.
|
||||
|
@ -1,11 +1,9 @@
|
||||
[Unit]
|
||||
Description=EncFS for data dir
|
||||
Before=postgresql@12-main.service
|
||||
BindsTo=postgresql@12-main.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/local/bin/mount_encfs
|
||||
ExecStop=/bin/umount /mnt/data
|
||||
ExecStop=/usr/local/bin/unmount_encfs
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -35,11 +35,17 @@ mount_directory = "/mnt/data"
|
||||
|
||||
template "/usr/local/bin/mount_encfs" do
|
||||
source "mount_encfs.erb"
|
||||
mode "0700"
|
||||
mode "0755"
|
||||
variables encrypted_directory: encrypted_directory,
|
||||
mount_directory: mount_directory
|
||||
end
|
||||
|
||||
template "/usr/local/bin/unmount_encfs" do
|
||||
source "unmount_encfs.erb"
|
||||
mode "0700"
|
||||
variables mount_directory: mount_directory
|
||||
end
|
||||
|
||||
execute "systemctl daemon-reload" do
|
||||
command "systemctl daemon-reload"
|
||||
action :nothing
|
||||
@ -50,19 +56,22 @@ directory mount_directory do
|
||||
mode "0775"
|
||||
end
|
||||
|
||||
execute "create encrypted file system" do
|
||||
command <<-EOF
|
||||
echo "y\\\n
|
||||
y\\\n
|
||||
p\\\n
|
||||
#{encfs_password}\\\n
|
||||
#{encfs_password}\\\n
|
||||
" | encfs #{encrypted_directory} #{mount_directory} --public --stdinpass
|
||||
EOF
|
||||
sensitive true
|
||||
not_if { ::File.exist?(encrypted_directory) }
|
||||
end
|
||||
# FIXME the password that is stored using this script does not match the actual password
|
||||
# execute "create encrypted file system" do
|
||||
# command <<-EOF
|
||||
# echo "y\\\n
|
||||
# y\\\n
|
||||
# FIXME paranoia mode breaks hard links, which postgres relies on
|
||||
# p\\\n
|
||||
# #{encfs_password}\\\n
|
||||
# #{encfs_password}\\\n
|
||||
# " | encfs #{encrypted_directory} #{mount_directory} --public --stdinpass
|
||||
# EOF
|
||||
# sensitive true
|
||||
# not_if { ::File.exist?(encrypted_directory) }
|
||||
# end
|
||||
|
||||
# FIXME there seems to be half a comment missing here
|
||||
# The service will automatically
|
||||
cookbook_file "/lib/systemd/system/encfs.service" do
|
||||
source "encfs.service"
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
systemd-ask-password --echo "encfs password:" | encfs <%= @encrypted_directory %> <%= @mount_directory %> --public --stdinpass
|
||||
echo "Encrypted data directory mounted as <%= @mount_directory %>" > /tmp/data-dir-mounted.txt
|
||||
|
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Start <%= @service_unit %> when encrypted data directory is mounted
|
||||
|
||||
[Path]
|
||||
PathExists=/tmp/data-dir-mounted.txt
|
||||
Unit=<%= @service_unit %>
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
4
site-cookbooks/kosmos_encfs/templates/unmount_encfs.erb
Normal file
4
site-cookbooks/kosmos_encfs/templates/unmount_encfs.erb
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm /tmp/data-dir-mounted.txt
|
||||
/bin/umount <%= @mount_directory %>
|
Loading…
x
Reference in New Issue
Block a user