Last active
August 29, 2015 14:19
-
-
Save calum-github/15b4739c85ccf7813d82 to your computer and use it in GitHub Desktop.
This script sets up a centos7 server as a linux netboot server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Set some variables | |
| samba_user_name="smbuser" | |
| samba_user_password="password" | |
| # This will attempt to get the IP address for the server. YMMV with this, if in doubt, hardcode the IP address of your server here. | |
| my_ip_address=`ip addr | grep "en" | awk '/inet/ {print $2}' | cut -d "/" -f1` | |
| # Install some packages | |
| echo "Installing Packages" | |
| yum -y update | |
| yum -y install docker nano samba samba-client | |
| # Create nbi directory | |
| echo "Creating /nbi directory" | |
| mkdir /nbi | |
| # Enable Docker Service | |
| echo "Enabling Docker" | |
| service docker start | |
| chkconfig docker on | |
| # Pull down the docker image | |
| echo "Getting bsdpy docker image" | |
| docker pull hunty1/bsdpydocker | |
| # Add our samba_user | |
| echo "*** Creating user account for samba share ***" | |
| useradd $samba_user_name | |
| echo -ne $samba_user_password$samba_user_password | smbpasswd -a -s $samba_user_name | |
| echo "*** Setting owner of /nbi to samba user $samba_user_name ***" | |
| chown -R $samba_user_name /nbi | |
| # Setup samba conf | |
| echo "*** Setting up smb.conf file ***" | |
| mv /etc/samba/smb.conf /etc/samba/smb.conf.backup | |
| echo "## Minimal SMB Conf file for CentOS 7 | |
| [global] | |
| workgroup = MYGROUP | |
| server string = Samba Server Version %v | |
| log file = /var/log/samba/log.%m | |
| max log size = 50 | |
| security = user | |
| passdb backend = tdbsam | |
| local master = no | |
| create mask = 0744 | |
| force create mode = 0744 | |
| directory mask = 0755 | |
| force directory mode = 0755 | |
| inherit permissions = yes | |
| load printers = no | |
| printing = bsd | |
| printcap name = /dev/null | |
| #============================ Share Definitions ============================== | |
| [nbi] | |
| path = /nbi | |
| available = yes | |
| read only = no | |
| browseable = yes | |
| public = no | |
| writable = yes" >> /etc/samba/smb.conf | |
| # Enable samba | |
| echo "*** Enabling Samba service ***" | |
| systemctl start smb | |
| systemctl start nmb | |
| systemctl enable smb | |
| systemctl enable nmb | |
| # Start docker container | |
| echo "Starting Docker container: netboot_server" | |
| docker run --restart=always -d -v /nbi:/nbi -p 69:69/udp -p 67:67/udp -p 80:80 -e "TZ=Australia/Sydney" -e BSDPY_IP=$my_ip_address --name netboot_server hunty1/bsdpydocker | |
| # Completes | |
| echo "Setup Complete!" | |
| echo "Upload your Netboot image via the samba share smb://${my_ip_address} then reboot this server when done, or restart the netboot docker container" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment