Boston Linux & UNIX was originally founded in 1994 as part of The Boston Computer Society. We meet on the third Wednesday of each month at the Massachusetts Institute of Technology, in Building E51.

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] Scripting help



We use a java tool called jexplorer. I'm not sure where the Canadians
found it. Our LDAP server is in Ottawa. I am unfamiliar with Zentyal. I
hate shell scripts that prompt. Recently I have converted them to simple
Python gui apps where you can fill in all the information on a panel,
and then click on a run button, and the first thing the script does is
validate your input. In this way you are not half way through the script
and forgot something.

On 02/17/2014 10:33 AM, Steven Santos wrote:
> So, my scripting fu isn't great.  This mostly works, but I need some
> help with it.
>
> I know what needs to be done to get CUPS and SANE working, but I don't
> know how to make the changes (see the script below)
>
> I am not sure of the best way to install a .deb package via a script
> (help would be appreciated)
>
> I would love to be able to run a script on the server to modify this
> with the correct LDAP information, possibly eventually create a way to
> download a filled in version from the Zentyal admin screen.
>
>
>
> #!/bin/sh
>
> ######################################################################
> ######################################################################
> #
> # This script is designed for Ubuntu 12.10.  It may or may not work
> with other versions.
> # This script will set up a computer to be a client on a Zentyal
> network, including the following services:
> # - Log-in via ldap
> # - Mount home directories from the server
> # - Mount shared directories from the server
> # - Tell CUPS to print via CUPS on the server
> # - Tell SANE to pickup shared scanners on the server
> # - Enable partner repos
> # - Add additional repos
> # - Install additional software
> #
> # This script makes the following assumptions:
> # - You have a working Zentyal installation
> # - You have users set up on the Zentyal server
> # - You have opened up port 390 on the Zentyal server
> # - You have set up and exported /home and /shared shares from the server
> # - You have set up and shared out any printers via CUPS
> # - You have set up and shared out any scanners via SANED
> #
> # This script sets up standard repositories and software for the network
> #
> # This script MUST be run as root
> #
> ######################################################################
> ######################################################################
>
>
> ######################################################################
> ######################################################################
> # This section sets the LDAP information.
> # Edit the following to match your Zentyal server
> # Make sure you do NOT have a space before or after the equal sign
> ######################################################################
> ldapserver=192.168.0.1                   # IP address or hostname
> basedn=dc=office,dc=lan                  # The domain Zentyal is on
> rootdn=cn=zentyal,dc=office,dc=lan       # The root DN
> passwort=rVhH5PIgaDYwZFNdAPi2            # The password
> ######################################################################
> # If you are unsure of your basedn, from the Zentyal dash board:
> ->"Users and Groups" -> "LDAP settings" -> "LDAP information" -> #
> Base DN
> ######################################################################
> # The uri is the IP address of your Zentyal box. Zentyal uses  Port
> 390 to reach ldap (the port is added by the script later)
> ######################################################################
> # If you are unsure of the rootnd and/or password, you can either:
> # from the Zentyal dash board: ->"Users and Groups" -> "LDAP settings"
> -> "LDAP information" -> LDAP USER
> # OR from a terminal on the zentyal server, run the following commands:
> # sudo grep ^binddn /etc/ldap.conf
> # sudo grep ^bindpw /etc/ldap.conf
> ######################################################################
> ######################################################################
>
>
> ######################################################################
> ######################################################################
> # Set the values for the 'ldap-auth-config' Installer
> ######################################################################
> echo "Set the values for the 'ldap-auth-config' Installer"
> # LDAP-Server
> echo "ldap-auth-config ldap-auth-config/ldapns/ldap-server string
> $ldapserver:390" | debconf-set-selections
> # Distinguished Name (baseDN)
> echo "ldap-auth-config ldap-auth-config/ldapns/base-dn string $basedn"
> | debconf-set-selections
> # LDAP version
> echo "ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3"
> | debconf-set-selections
> # Local Database Root
> echo "ldap-auth-config ldap-auth-config/dbrootlogin boolean true" |
> debconf-set-selections
> # No database login requiered
> echo "ldap-auth-config ldap-auth-config/dblogin boolean false" |
> debconf-set-selections
> # LDAP root-Account
> echo "ldap-auth-config ldap-auth-config/rootbinddn string $rootdn" |
> debconf-set-selections
> # LDAP-root Passwd
> echo "ldap-auth-config ldap-auth-config/bindpw password $passwort" |
> debconf-set-selections
> echo "ldap-auth-config ldap-auth-config/rootbindpw password $passwort"
> | debconf-set-selections
> ######################################################################
> ######################################################################
>
>
>
>
> ######################################################################
> ######################################################################
> # Install the packages for ldap
> ######################################################################
>
> # Install ldap-auth-config and nscd
> echo "Installing 'ldap-auth-config' and 'nscd'"
> apt-get install -y ldap-auth-config nscd
>
> # Setup nss
> echo "Setting up nss"
> auth-client-config -t nss -p lac_ldap
>
> # Restart ldap and nss
> echo "Restarting the'libnss-ldap' and 'nscd' daemons"
> /etc/init.d/libnss-ldap restart
> /etc/init.d/nscd restart
> ######################################################################
> ######################################################################
>
>
>
> ######################################################################
> ######################################################################
> # Set up the NFS mounts for /home
> ######################################################################
> # Install NFS-common
> echo "Installing 'nfs-common'"
> apt-get install -y nfs-common
>
> # Establish the fstab entry...
> fstabEintrag="$ldapserver:/home /home nfs rw 0 0"
>
> # Test whether a corresponding entry in the /etc/fstab file has
> already been created
> if grep -Exq "$ldapserver:/home[[:space:]]+/home[[:space:]]+nfs[[:space:]]+rw[[:space:]]+0[[:space:]]+0[[:space:]]*"
> /etc/fstab ||
> #Oder, ob home schon Mountpunkt ist
> grep -Exq ".+:/.+[[:space:]]+/home[[:space:]]+.*" /etc/fstab
> then
> echo "Mount point"
> echo "$fstabEintrag"
> echo "already exists."
> else
> echo "Adding $fstabEintrag to /etc/fstab"
> cp /etc/fstab /etc/fstab.orig
> echo $fstabEintrag >> /etc/fstab
> fi
>
>
> #Test whether the NFS server exports the home directories
>
> if showmount -e $ldapserver | grep -Ex "/home[[:space:]]+.*"
> then
> echo "Mounting home"
> mount -a
> else
> echo "The host $ldapserver did not export the /home directory"
> echo "You need to install 'nfs-kernel-server' and put an entry"
> echo "for /home in /etc/exports"
> fi;
> ######################################################################
> ######################################################################
>
>
>
> ######################################################################
> # Add other shares under /shared
> ######################################################################
> mkdir /shared                    # Make the shared directory
> # Establish the fstab entry...
> fstabshared="$ldapserver:/shared /shared nfs rw 0 0"
>
> # Test whether a corresponding entry in the /etc/fstab file has
> already been created
> if grep -Exq "$ldapserver:/shared[[:space:]]+/shared[[:space:]]+nfs[[:space:]]+rw[[:space:]]+0[[:space:]]+0[[:space:]]*"
> /etc/fstab ||
> #Oder, ob home schon Mountpunkt ist
> grep -Exq ".+:/.+[[:space:]]+/home[[:space:]]+.*" /etc/fstab
> then
> echo "Mount point"
> echo "$fstabshared"
> echo "already exists."
> else
> echo "Adding $fstabshared to /etc/fstab"
> cp /etc/fstab /etc/fstab.orig1
> echo $fstabshared >> /etc/fstab
> fi
> #Test whether the NFS server exports the shared directories
>
> if showmount -e $ldapserver | grep -Ex "/shared[[:space:]]+.*"
> then
> echo "Mounting /shared"
> mount -a
> else
> echo "The host $ldapserver did not export the /shared directory"
> echo "You need to install 'nfs-kernel-server' and put an entry"
> echo "for /shared in /etc/exports"
> fi;
> ######################################################################
> ######################################################################
>
>
> ######################################################################
> ######################################################################
> # Set up LightDM to use ldap
> ######################################################################
> echo "Fixing the log-in screen"
> echo ""
> cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.orig
> if grep -Exq "greeter-hide-users=.*" /etc/lightdm/lightdm.conf
> then
> sed -i '/greeter-hide-users=.*/d' /etc/lightdm/lightdm.conf
> fi
> echo "greeter-hide-users=true" >= /etc/lightdm/lightdm.conf
> ######################################################################
> ######################################################################
>
>
> ######################################################################
> ######################################################################
> # Set up CUPS
> ######################################################################
> # CUPS defaults to not showing printers shared by other systems. In
> order to show the printers from the server, we need to modify
> /etc/cups/cupsd.conf and create /etc/cups/client.conf
> # This script needs to create /etc/cups/client.conf and add the line
> # ServerName $ldapserver
> #
> # In /etc/cups/cupsd.conf this script needs to change the line
> # Browsing Off
> # to
> # Browsing On
> ######################################################################
> ######################################################################
>
>
> ######################################################################
> ######################################################################
> # Set up SANE
> ######################################################################
> # We want the workstations to pick up any scanners shared out via
> saned on the server.  To do that, we need to make changes in
> /etc/sane.d/net.conf
> # First, we need to find the line that reads "## saned hosts" and
> append the line "$ldapserver" after that line
> # Second, we need to find the line that reads "# connect_timeout = 60"
> and replace it with "connect_timeout = 60"
> #
> ######################################################################
>
>
>
> ######################################################################
> ######################################################################
> echo  "Configuration completed. Try"
> echo  "su <user on the ldap server>"
> echo  "to log in with a user of the LDAP server."
> ######################################################################
> ######################################################################
>
>
>
> ######################################################################
> ######################################################################
> # Set up additional software repositories for our standard workstation
> ######################################################################
> # This will set up additional repositories for the workstations and
> install the packages to those workstations
>
> # Enable partner repositories
> echo "Enabling Partner Repositories" &&
> sed -i "/^# deb .*partner/ s/^# //" /etc/apt/sources.list
>
> # Add the videolan repo
> echo "Enabling VideoLAN repository"
> add-apt-repository -y ppa:videolan/stable-daily
>
> # Add the rhythmbox repo
> echo "Enabling Rhythmbox repository"
> add-apt-repository -y ppa:webupd8team/rhythmbox
>
> # Add the gimp repo
> echo "Enabling GNU Image Manipulation Program (GIMP) repository"
> add-apt-repository -y ppa:otto-kesselgulasch/gimp
>
> # Chrome
> echo "Enabling Google Chrome repository"
> wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub |
> sudo apt-key add -
> sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main"
>>> /etc/apt/sources.list.d/google-chrome.list'
> ######################################################################
> ######################################################################
>
>
>
> ######################################################################
> ######################################################################
> # Download and install our standard workstation packages...
> ######################################################################
> # This will set up additional repositories for the workstations and
> install the packages to those workstations
>
> echo "Updating package lists..."
> apt-get -qq update
> echo "Upgrading existing packages to the latest versions..."
> apt-get upgrade
>
>
> # Make Human
> # No repo for this, need to download and install dep package
> # http://download.tuxfamily.org/makehuman/releases/makehuman_1.0.alpha.8.rc1/makehuman_1.0.alpha.8.rc1_all.deb
>
> apt-get install google-chrome-stable vlc gimp gimp-data
> gimp-plugin-registry gimp-data-extras
>
> echo "Cleaning Up"
> apt-get -f install
> apt-get autoremove
> apt-get -y autoclean
> apt-get -y clean
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://lists.blu.org/mailman/listinfo/discuss

-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix
PGP key id:3BC1EB90 
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org