+sub writeconfiguration() {
+ open (FILE, ">${General::swroot}/samba/global") or die "Can't save the global settings: $!";
+ flock (FILE, 2);
+
+ print FILE <<END;
+# global.settings by IPFire Project
+
+[global]
+server string = Samba on IPFire
+
+workgroup = $sambasettings{'WORKGRP'}
+realm = $mainsettings{'DOMAINNAME'}
+passdb backend = smbpasswd
+
+map to guest = $sambasettings{'MAPTOGUEST'}
+
+guest account = $sambasettings{'GUESTACCOUNT'}
+unix password sync = no
+
+bind interfaces only = true
+interfaces = green0 blue0 127.0.0.0/8
+remote announce = $sambasettings{'REMOTEANNOUNCE'}
+remote browse sync = $sambasettings{'REMOTESYNC'}
+
+winbind separator = +
+winbind uid = 10000-20000
+winbind gid = 10000-20000
+winbind use default domain = yes
+
+# Log to syslog
+logging = syslog
+
+# Enable support for Apple
+vfs objects = catia fruit streams_xattr recycle
+
+# Enable following symlinks
+wide links = yes
+
+END
+
+# Server Role
+if ($sambasettings{'ROLE'} eq "standalone") {
+ print FILE "server role = standalone\n";
+} elsif ($sambasettings{'ROLE'} eq "member") {
+ print FILE "server role = member server\n";
+}
+
+if ($sambasettings{'ENCRYPTION'} =~ m/(desired|required)/) {
+ print FILE "smb encrypt = $1\n";
+}
+
+print FILE <<END;
+# Export all printers
+[printers]
+path = /var/spool/samba/
+printable = yes
+
+END
+close FILE;
+
+ system("/usr/local/bin/sambactrl smbsafeconf");
+}
+