This Blueprint sets up a Samba Share for the WinPE installation.
Contents
Setup Samba Share for Windows OS Files on macOS or Linux
Step 1 - Install Samba on Linux
Step 2 - Setup Shared Folder on Linux
Step 3 - Configure SELinux Security Context on Linux
Step 4 - Setup smb.conf on Linux
Step 5 - Check smb.conf on Linux
Step 6 - Setup Firewall for Samba on Linux
Step 7 - Install Prerequisites on Linux
Step 8 - Setup SELinux for Samba on Linux
Step 9 - Check SELinux for Samba on Linux
Step 11 - Check Service smb on Linux
Step 12 - Start Service nmb on Linux
Automate This
Use the Attune GUI for your Scripts
You've automated: Setup Samba Share for Windows OS Files on macOS or Linux
Get the most out of automation with our get started videos, product demonstrations, and more.
The following steps will guide you through the manual process.
Install packages required for Samba.
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
dnf -y install samba samba-common samba-client
elif [[ -f /etc/debian_version ]]
then
apt -y install samba samba-common samba-client
elif [[ "Darwin" == "$(uname)" ]]
then
brew install samba
else
echo "Unsupported operating system."
exit 1
fi
Execute the following script:
shared_dir="{automationWorkerLinuxBaseDirectory}/windows_iso_data_for_winpe"
USER="{automationWorkerLinuxUser.user}"
GROUP="$(id -gn $USER)"
echo "User: $USER, Group: $GROUP"
mkdir -p $shared_dir
chmod -R 0775 $shared_dir
chown -R nobody:$GROUP $shared_dir
ls -lrh $shared_dir
Execute the following script:
shared_dir="{automationWorkerLinuxBaseDirectory}/windows_iso_data_for_winpe"
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
chcon -R -t samba_share_t $shared_dir
elif [[ -f /etc/debian_version ]]
then
echo "This is Debian, Nothing to do!"
elif [[ "Darwin" == "$(uname)" ]]
then
echo "This is macOS, Nothing to do!"
else
echo "Unsupported operating system."
exit 1
fi
Populate /etc/samba/smb.conf
.
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]] || [[ -f /etc/debian_version ]]
then
cd /etc/samba/
elif [[ "Darwin" == "$(uname)" ]]
then
cd /usr/local/etc/
else
echo "Unsupported operating system."
exit 1
fi
cat << EOF > smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = WORKGROUP
security = user
passdb backend = tdbsam
map to guest = bad user
[share]
comment = public share
path = {automationWorkerLinuxBaseDirectory}/windows_iso_data_for_winpe
browseable = yes
guest ok = yes
guest only = yes
writable = yes
read only = no
EOF
cat smb.conf
Connect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
testparm --suppress-prompt
exit $?
Open up firewall rules for Samba.
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
firewall-cmd --add-service=samba --zone=public --permanent
firewall-cmd --reload
elif [[ -f /etc/debian_version ]]
then
echo "This is Debian, Nothing to do!"
elif [[ "Darwin" == "$(uname)" ]]
then
echo "This is macOS, Nothing to do!"
else
echo "Unsupported operating system."
exit 1
fi
Installs packages required by Samba.
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
dnf -y install \
policycoreutils-python-utils \
fuse3-devel \
fuse3-libs \
epel-release \
p7zip p7zip-plugins
elif [[ -f /etc/debian_version ]]
then
apt-get -y install \
policycoreutils \
libfuse3-dev \
fuse3 \
p7zip-full p7zip-rar
elif [[ "Darwin" == "$(uname)" ]]
then
brew install osxfuse p7zip
else
echo "Unsupported operating system."
exit 1
fi
Sets up SELinux for Samba.
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
if sestatus | grep -i "SELinux status:" | grep -q "enabled"
then
setsebool -P samba_export_all_ro=1 samba_export_all_rw=1
semanage fcontext -at samba_share_t "{automationWorkerLinuxBaseDirectory}/windows_iso_data_for_winpe(/.*)?"
else
echo "SElinux is disabled"
fi
elif [[ -f /etc/debian_version ]]
then
echo "This is Debian, Nothing to do!"
elif [[ "Darwin" == "$(uname)" ]]
then
echo "This is macOS, Nothing to do!"
else
echo "Unsupported operating system."
exit 1
fi
Checks if SELinux is set up correctly for Samba.
Connect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
if [[ -f /etc/redhat-release ]] || [[ -f /etc/lsb-release ]]
then
if sestatus | grep -i "SELinux status:" | grep -q "enabled"
then
line_count=$(getsebool -a | grep samba_export | wc -l)
if [ $line_count -eq 2 ]
then
echo "ok"
else
echo "wrong number of occurrences for samba_export"
exit 1
fi
else
echo "SElinux is disabled"
fi
elif [[ -f /etc/debian_version ]]
then
echo "This is Debian, Nothing to do!"
elif [[ "Darwin" == "$(uname)" ]]
then
echo "This is macOS, Nothing to do!"
else
echo "Unsupported operating system."
exit 1
fi
Starts smb
service.
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
systemctl restart smb
systemctl enable smb
systemctl status smb
Checks if the smb
service is running.
Connect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
service="smb"
line_count=$(systemctl status $service | grep running | wc -l)
if [ $line_count -eq 0 ]
then
echo "$service is not running"
exit 1
else
echo "ok"
fi
Starts nmb
service.
Connect via ssh:
ssh {automationworkerlinuxuserroot}@{automationworkerlinuxnode}
Execute the following script:
systemctl restart nmb
systemctl enable nmb
systemctl status nmb
Checks if nmb
service is running.
Connect via ssh:
ssh {automationworkerlinuxuser}@{automationworkerlinuxnode}
Execute the following script:
service="nmb"
line_count=$(systemctl status $service | grep running | wc -l)
if [ $line_count -eq 0 ]
then
echo "$service is not running"
exit 1
else
echo "ok"
fi
Sets the permissions of the home folder.
Execute the following script:
chmod -v +rx $HOME
You have completed this instruction.
Join our Discord channel and connect with like-minded individuals who share your passion. Engage in lively discussions, gain valuable insights, and stay updated on the latest trends in our industry. Don't miss out on this opportunity to network, learn, and grow together.
Click the link below and become a part of our vibrant community on Discord today!