#!/bin/bash # this is from distro-end if [[ $HOSTNAME == kd ]]; then pi samba # note samba re-reads it\'s config every 1 minute case $distro in arch) s cp /etc/samba/smb.conf.default /etc/samba/smb.conf ;; esac # add 2 lines after workgroup option s sed -ri --follow-symlinks '/^\s*encrypt passwords\s*=/d' /etc/samba/smb.conf s sed -ri --follow-symlinks '/^\s*map to guest\s*=/d' /etc/samba/smb.conf s sed -i --follow-symlinks 's/\(\s*workgroup\s*=\).*/\1 WORKGROUP\n\tencrypt passwords = yes\n\tmap to guest = bad password/' /etc/samba/smb.conf # remove default homes section. not sharing that. s sed -ri --follow-symlinks '/^\s*\[homes\]/,/\s*\[/d' /etc/samba/smb.conf if ! grep -xF '[public]' /etc/samba/smb.conf &>/dev/null; then s tee -a /etc/samba/smb.conf <<'EOF' [public] guest ok = yes read only = no path = /kr EOF fi case $distro in debian|trisquel|ubuntu) # systemd claims it generates units from /etc/init.d, but it # clearly doesn\'t in debian. I have no idea how they are # related. fuck debian right now. It\'s not documented. samba # has a systemd init file linked to /dev/null. There\'s this # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769714 which # claims samba\'s sub-services will be started automatically by # systemd... it didn\'t on install, wonder if it will on # boot. It clued me in how to start it manually though. Nothing # in /usr/share/doc/samba, debian admin guide says nothing about # any of this. (this is in debian testing as of 4/2016). s /etc/init.d/samba start ;; arch) sgo samba ;; esac fi