summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/set_password.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/set_password.rb b/scripts/set_password.rb
index 71bdc41..0b83861 100644
--- a/scripts/set_password.rb
+++ b/scripts/set_password.rb
@@ -23,4 +23,13 @@ File.write(tmp, config.to_yaml)
File.rename(tmp, CONFIG_PATH)
File.chmod(0o600, CONFIG_PATH)
+# Ensure the service user can read the file even when this script is run as root.
+begin
+ require 'etc'
+ pw = Etc.getpwnam('albumen')
+ File.chown(pw.uid, pw.gid, CONFIG_PATH)
+rescue ArgumentError
+ # 'albumen' user doesn't exist (dev environment); leave ownership as-is
+end
+
puts "Password set. Config written to #{CONFIG_PATH}"