#!/bin/bash
export PATH=$PATH:/sbin:/usr/sbin
apt update
apt install -y kmod net-tools ksmbd-tools build-essential dkms
apt install -y sudo
apt install -y smbclient

mkdir -p /etc/ksmbd

cat << EOF > /etc/ksmbd/smb.conf
[global]
    server string = ksmbd on Debian
    workgroup = WORKGROUP
    log level = 3
    usershare path = /srv/ksmbd/usershares

[share]
    path = /srv/ksmbd/share
    read only = no
    guest ok = yes
EOF

mkdir -p /srv/ksmbd/share
mkdir -p /srv/ksmbd/usershares
chown nobody:nogroup /srv/ksmbd/share
chmod 0777 /srv/ksmbd/share
touch /srv/ksmbd/share/works.txt

modprobe ksmbd
ksmbd.mountd
systemctl daemon-reload
systemctl enable --now ksmbd.service
ksmbd.control -d "all"
