diff --git a/samba/Containerfile b/samba/Containerfile index 52033a7..d29384f 100644 --- a/samba/Containerfile +++ b/samba/Containerfile @@ -48,3 +48,9 @@ RUN systemctl disable nmbd # copy samba config COPY assets/smb.conf /etc/samba/smb.conf + +# copy db-load service +COPY assets/db-load.service /etc/systemd/system/ + +# enable db-load service +RUN systemctl enable db-load.service diff --git a/samba/assets/bin/smbadduser b/samba/assets/bin/smbadduser index b0adfde..db3b9df 100755 --- a/samba/assets/bin/smbadduser +++ b/samba/assets/bin/smbadduser @@ -4,3 +4,5 @@ if [[ -z $(getent passwd "$1") ]]; then usermod -a -G sambashare "$1" fi smbpasswd -a "$1" + +db-dump /vol/data/smbpasswd diff --git a/samba/assets/db-load.service b/samba/assets/db-load.service new file mode 100644 index 0000000..2a79938 --- /dev/null +++ b/samba/assets/db-load.service @@ -0,0 +1,12 @@ +[Unit] +Description=Load database on startup +Before=smbd.service +After=network-online.target + +[Service] +Type=oneshot +EnvironmentFile=/etc/environment +ExecStart=/bin/bash -c "db-load /vol/data/smbpasswd" + +[Install] +WantedBy=multi-user.target