diff --git a/files/akb.netz/homedirs/DEFAULT/_profile.j2 b/files/akb.netz/homedirs/DEFAULT/_profile.j2 index c11c9be..fb47ea6 100644 --- a/files/akb.netz/homedirs/DEFAULT/_profile.j2 +++ b/files/akb.netz/homedirs/DEFAULT/_profile.j2 @@ -48,9 +48,12 @@ export LANG="de_DE.utf8" # [[ "$(hostname --long)" = "{{ samba_server }}" ]] && return +# Don't try to mount samba shares if local mount base directory does not exist +[[ -d "/mnt/{{ user.name }}" ]] || return + SERVER="{{ samba_server }}" -USER="{{ item.item.name }}" -PASSWORD='{{ item.item.password }}' +USER="{{ user.name }}" +PASSWORD='{{ user.password }}' #VERSION="1.0" # Use NTLMv2 password hashing and force packet signing diff --git a/files/akb.netz/homedirs/DEFAULT/_profile.j2.00 b/files/akb.netz/homedirs/DEFAULT/_profile.j2.00 new file mode 100644 index 0000000..c11c9be --- /dev/null +++ b/files/akb.netz/homedirs/DEFAULT/_profile.j2.00 @@ -0,0 +1,133 @@ +# {{ ansible_managed }} + +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# this is for the midnight-commander +# to become the last directory the midnight commander was in +# as the current directory when leaving the midnight commander +# +if [ -f "/usr/share/mc/bin/mc.sh" ]; then + source /usr/share/mc/bin/mc.sh +elif [ -f "/usr/lib/mc/bin/mc.sh" ] ; then + source /usr/lib/mc/bin/mc.sh +fi + +export LANG="de_DE.utf8" + +# --- +# Mmount samba shares +# --- + +# Don't try to mount samba shares if login at samba server +# +[[ "$(hostname --long)" = "{{ samba_server }}" ]] && return + +SERVER="{{ samba_server }}" +USER="{{ item.item.name }}" +PASSWORD='{{ item.item.password }}' +#VERSION="1.0" + +# Use NTLMv2 password hashing and force packet signing +# +# SEC="ntlmv2i" +# +# Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing +# +# SEC="ntlmsspi" +# +SEC="ntlmsspi" + +# - uid/guid of the user at fielserver +# - +_UID="$(id -u)" +_GID="$(id -g)" + + +# Logfile to see what happened.. +# +_logfile=/tmp/profile_${USER}.log + + +echo "" > $_logfile +echo "$(date +"%Y-%m-%d-%H%M")" >> $_logfile + +# Network present +# +_network=false + +if [ "X$_addr" = "X" ] ; then + echo "no inet address assigned yet.." >> $_logfile + declare -i count=1 + while ! $_network && [[ $count -lt 5 ]] ; do + echo "sleeping 2 seconds.." >> $_logfile + sleep 2 + _addr="$(hostname --ip-address)" + if [ "X$_addr" != "X" ] ; then + _network=true + echo "inet address present: $_addr" >> $_logfile + fi + ((count++)) + done +fi + +for dir in $(ls /mnt/$USER) ; do + MOUNT_POINT=/mnt/$USER/$dir + SHARE=$dir + + [ ! -d $MOUNT_POINT ] && continue + + if ! mount | grep $MOUNT_POINT > /dev/null ; then + echo "Going to mount share '${SHARE}' .." >> $_logfile + if [ -x /usr/bin/smb4k_mount ]; then + ## - Ubuntu <= 12.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID,vers=$VERSION \ + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + else + ## - Ubuntu Version >= 14.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,sec=${SEC},vers=$VERSION \ + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$USER,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + fi + else + echo "mount point $MOUNT_POINT already exists. nothing left to do.." >> $_logfile + fi + +done + diff --git a/files/anw-kb.netz/homedirs/DEFAULT/_profile.j2 b/files/anw-kb.netz/homedirs/DEFAULT/_profile.j2 index c11c9be..fb47ea6 100644 --- a/files/anw-kb.netz/homedirs/DEFAULT/_profile.j2 +++ b/files/anw-kb.netz/homedirs/DEFAULT/_profile.j2 @@ -48,9 +48,12 @@ export LANG="de_DE.utf8" # [[ "$(hostname --long)" = "{{ samba_server }}" ]] && return +# Don't try to mount samba shares if local mount base directory does not exist +[[ -d "/mnt/{{ user.name }}" ]] || return + SERVER="{{ samba_server }}" -USER="{{ item.item.name }}" -PASSWORD='{{ item.item.password }}' +USER="{{ user.name }}" +PASSWORD='{{ user.password }}' #VERSION="1.0" # Use NTLMv2 password hashing and force packet signing diff --git a/files/flr.netz/homedirs/DEFAULT/_profile.j2 b/files/flr.netz/homedirs/DEFAULT/_profile.j2 index c11c9be..b655d82 100644 --- a/files/flr.netz/homedirs/DEFAULT/_profile.j2 +++ b/files/flr.netz/homedirs/DEFAULT/_profile.j2 @@ -45,12 +45,14 @@ export LANG="de_DE.utf8" # --- # Don't try to mount samba shares if login at samba server -# [[ "$(hostname --long)" = "{{ samba_server }}" ]] && return +# Don't try to mount samba shares if local mount base directory does not exist +[[ -d "/mnt/{{ user.name }}" ]] || return + SERVER="{{ samba_server }}" -USER="{{ item.item.name }}" -PASSWORD='{{ item.item.password }}' +USER="{{ user.name }}" +PASSWORD='{{ user.password }}' #VERSION="1.0" # Use NTLMv2 password hashing and force packet signing diff --git a/files/flr.netz/homedirs/DEFAULT/_profile.j2.00 b/files/flr.netz/homedirs/DEFAULT/_profile.j2.00 new file mode 100644 index 0000000..c11c9be --- /dev/null +++ b/files/flr.netz/homedirs/DEFAULT/_profile.j2.00 @@ -0,0 +1,133 @@ +# {{ ansible_managed }} + +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# this is for the midnight-commander +# to become the last directory the midnight commander was in +# as the current directory when leaving the midnight commander +# +if [ -f "/usr/share/mc/bin/mc.sh" ]; then + source /usr/share/mc/bin/mc.sh +elif [ -f "/usr/lib/mc/bin/mc.sh" ] ; then + source /usr/lib/mc/bin/mc.sh +fi + +export LANG="de_DE.utf8" + +# --- +# Mmount samba shares +# --- + +# Don't try to mount samba shares if login at samba server +# +[[ "$(hostname --long)" = "{{ samba_server }}" ]] && return + +SERVER="{{ samba_server }}" +USER="{{ item.item.name }}" +PASSWORD='{{ item.item.password }}' +#VERSION="1.0" + +# Use NTLMv2 password hashing and force packet signing +# +# SEC="ntlmv2i" +# +# Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing +# +# SEC="ntlmsspi" +# +SEC="ntlmsspi" + +# - uid/guid of the user at fielserver +# - +_UID="$(id -u)" +_GID="$(id -g)" + + +# Logfile to see what happened.. +# +_logfile=/tmp/profile_${USER}.log + + +echo "" > $_logfile +echo "$(date +"%Y-%m-%d-%H%M")" >> $_logfile + +# Network present +# +_network=false + +if [ "X$_addr" = "X" ] ; then + echo "no inet address assigned yet.." >> $_logfile + declare -i count=1 + while ! $_network && [[ $count -lt 5 ]] ; do + echo "sleeping 2 seconds.." >> $_logfile + sleep 2 + _addr="$(hostname --ip-address)" + if [ "X$_addr" != "X" ] ; then + _network=true + echo "inet address present: $_addr" >> $_logfile + fi + ((count++)) + done +fi + +for dir in $(ls /mnt/$USER) ; do + MOUNT_POINT=/mnt/$USER/$dir + SHARE=$dir + + [ ! -d $MOUNT_POINT ] && continue + + if ! mount | grep $MOUNT_POINT > /dev/null ; then + echo "Going to mount share '${SHARE}' .." >> $_logfile + if [ -x /usr/bin/smb4k_mount ]; then + ## - Ubuntu <= 12.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID,vers=$VERSION \ + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + else + ## - Ubuntu Version >= 14.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,sec=${SEC},vers=$VERSION \ + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$USER,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + fi + else + echo "mount point $MOUNT_POINT already exists. nothing left to do.." >> $_logfile + fi + +done + diff --git a/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2 b/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2 index 166c675..d36dbdd 100644 --- a/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2 +++ b/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2 @@ -51,11 +51,11 @@ export LANG="de_DE.utf8" # Only try mounting samba shares, if local mount base directory exists. # -if [[ -d "/mnt/{{ item.item.name }}" ]]; then +if [[ -d "/mnt/{{ user.name }}" ]]; then SERVER="{{ samba_server }}" - USER="{{ item.item.name }}" - PASSWORD='{{ item.item.password }}' + USER="{{ user.name }}" + PASSWORD='{{ user.password }}' #VERSION="1.0" # Use NTLMv2 password hashing and force packet signing diff --git a/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2.00 b/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2.00 new file mode 100644 index 0000000..166c675 --- /dev/null +++ b/files/mbr-bln.netz/homedirs/DEFAULT/_profile.j2.00 @@ -0,0 +1,140 @@ +# {{ ansible_managed }} + +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# this is for the midnight-commander +# to become the last directory the midnight commander was in +# as the current directory when leaving the midnight commander +# +if [ -f "/usr/share/mc/bin/mc.sh" ]; then + source /usr/share/mc/bin/mc.sh +elif [ -f "/usr/lib/mc/bin/mc.sh" ] ; then + source /usr/lib/mc/bin/mc.sh +fi + +export LANG="de_DE.utf8" + +# --- +# Mmount samba shares +# --- + +# Don't try to mount samba shares if login at samba server +# +[[ "$(hostname --long)" = "{{ samba_server }}" ]] && return + + +# Only try mounting samba shares, if local mount base directory exists. +# +if [[ -d "/mnt/{{ item.item.name }}" ]]; then + + SERVER="{{ samba_server }}" + USER="{{ item.item.name }}" + PASSWORD='{{ item.item.password }}' + #VERSION="1.0" + + # Use NTLMv2 password hashing and force packet signing + # + # SEC="ntlmv2i" + # + # Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing + # + # SEC="ntlmsspi" + # + SEC="ntlmsspi" + + # - uid/guid of the user at fielserver + # - + _UID="$(id -u)" + _GID="$(id -g)" + + + # Logfile to see what happened.. + # + _logfile=/tmp/profile_${USER}.log + + + echo "" > $_logfile + echo "$(date +"%Y-%m-%d-%H%M")" >> $_logfile + + # Network present + # + _network=false + + if [ "X$_addr" = "X" ] ; then + echo "no inet address assigned yet.." >> $_logfile + declare -i count=1 + while ! $_network && [[ $count -lt 5 ]] ; do + echo "sleeping 2 seconds.." >> $_logfile + sleep 2 + _addr="$(hostname --ip-address)" + if [ "X$_addr" != "X" ] ; then + _network=true + echo "inet address present: $_addr" >> $_logfile + fi + ((count++)) + done + fi + + for dir in $(ls /mnt/$USER) ; do + MOUNT_POINT=/mnt/$USER/$dir + SHARE=$dir + + [ ! -d $MOUNT_POINT ] && continue + + if ! mount | grep $MOUNT_POINT > /dev/null ; then + echo "Going to mount share '${SHARE}' .." >> $_logfile + if [ -x /usr/bin/smb4k_mount ]; then + ## - Ubuntu <= 12.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID,vers=$VERSION \ + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + else + ## - Ubuntu Version >= 14.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,sec=${SEC},vers=$VERSION \ + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$USER,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + fi + else + echo "mount point $MOUNT_POINT already exists. nothing left to do.." >> $_logfile + fi + + done + +fi + diff --git a/files/sprachenatelier.netz/homedirs/DEFAULT/_profile b/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.BAK similarity index 100% rename from files/sprachenatelier.netz/homedirs/DEFAULT/_profile rename to files/sprachenatelier.netz/homedirs/DEFAULT/_profile.BAK diff --git a/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2 b/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2 index e0773a6..4a73a6f 100644 --- a/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2 +++ b/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2 @@ -14,7 +14,7 @@ if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" + . "$HOME/.bashrc" fi fi @@ -31,7 +31,6 @@ fi # this is for the midnight-commander # to become the last directory the midnight commander was in # as the current directory when leaving the midnight commander -# if [ -f "/usr/share/mc/bin/mc.sh" ]; then source /usr/share/mc/bin/mc.sh elif [ -f "/usr/lib/mc/bin/mc.sh" ] ; then @@ -41,52 +40,35 @@ fi export LANG="de_DE.utf8" # --- -# Mmount samba shares +# Mount samba shares # --- # Don't try to mount samba shares if login at samba server -# [[ "$(hostname --long)" = "{{ samba_server }}" ]] && return - # Don't try to mount samba shares if local mount base directory does not exist -# -[[ -d "/mnt/{{ item.item.name }}" ]] || return - +[[ -d "/mnt/{{ user.name }}" ]] || return SERVER="{{ samba_server }}" -USER="{{ item.item.name }}" -PASSWORD='{{ item.item.password }}' +USER="{{ user.name }}" +PASSWORD='{{ user.password }}' #VERSION="1.0" -# Use NTLMv2 password hashing and force packet signing -# -# SEC="ntlmv2i" -# # Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing -# -# SEC="ntlmsspi" -# SEC="ntlmsspi" -# - uid/guid of the user at fielserver -# - +# - uid/gid of the user at fileserver _UID="$(id -u)" _GID="$(id -g)" - # Logfile to see what happened.. -# _logfile=/tmp/profile_${USER}.log - echo "" > $_logfile echo "$(date +"%Y-%m-%d-%H%M")" >> $_logfile # Network present -# _network=false - if [ "X$_addr" = "X" ] ; then echo "no inet address assigned yet.." >> $_logfile declare -i count=1 @@ -106,9 +88,9 @@ for dir in $(ls /mnt/$USER) ; do MOUNT_POINT=/mnt/$USER/$dir SHARE=$dir - [ ! -d $MOUNT_POINT ] && continue + [ ! -d "$MOUNT_POINT" ] && continue - if ! mount | grep $MOUNT_POINT > /dev/null ; then + if ! mount | grep "$MOUNT_POINT" > /dev/null ; then echo "Going to mount share '${SHARE}' .." >> $_logfile if [ -x /usr/bin/smb4k_mount ]; then ## - Ubuntu <= 12.04 @@ -116,7 +98,6 @@ for dir in $(ls /mnt/$USER) ; do sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,vers=1.0 \ -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 else - #sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID,vers=$VERSION \ sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID \ -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 fi @@ -126,14 +107,12 @@ for dir in $(ls /mnt/$USER) ; do sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,vers=1.0 \ -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 else - #sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,sec=${SEC},vers=$VERSION \ - sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$USER,gid=$_GID \ + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,gid=$_GID \ -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 fi fi else echo "mount point $MOUNT_POINT already exists. nothing left to do.." >> $_logfile fi - done diff --git a/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2.00 b/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2.00 new file mode 100644 index 0000000..e0773a6 --- /dev/null +++ b/files/sprachenatelier.netz/homedirs/DEFAULT/_profile.j2.00 @@ -0,0 +1,139 @@ +# {{ ansible_managed }} + +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# this is for the midnight-commander +# to become the last directory the midnight commander was in +# as the current directory when leaving the midnight commander +# +if [ -f "/usr/share/mc/bin/mc.sh" ]; then + source /usr/share/mc/bin/mc.sh +elif [ -f "/usr/lib/mc/bin/mc.sh" ] ; then + source /usr/lib/mc/bin/mc.sh +fi + +export LANG="de_DE.utf8" + +# --- +# Mmount samba shares +# --- + +# Don't try to mount samba shares if login at samba server +# +[[ "$(hostname --long)" = "{{ samba_server }}" ]] && return + + +# Don't try to mount samba shares if local mount base directory does not exist +# +[[ -d "/mnt/{{ item.item.name }}" ]] || return + + +SERVER="{{ samba_server }}" +USER="{{ item.item.name }}" +PASSWORD='{{ item.item.password }}' +#VERSION="1.0" + +# Use NTLMv2 password hashing and force packet signing +# +# SEC="ntlmv2i" +# +# Use NTLMv2 password hashing encapsulated in Raw NTLMSSP message, and force packet signing +# +# SEC="ntlmsspi" +# +SEC="ntlmsspi" + +# - uid/guid of the user at fielserver +# - +_UID="$(id -u)" +_GID="$(id -g)" + + +# Logfile to see what happened.. +# +_logfile=/tmp/profile_${USER}.log + + +echo "" > $_logfile +echo "$(date +"%Y-%m-%d-%H%M")" >> $_logfile + +# Network present +# +_network=false + +if [ "X$_addr" = "X" ] ; then + echo "no inet address assigned yet.." >> $_logfile + declare -i count=1 + while ! $_network && [[ $count -lt 5 ]] ; do + echo "sleeping 2 seconds.." >> $_logfile + sleep 2 + _addr="$(hostname --ip-address)" + if [ "X$_addr" != "X" ] ; then + _network=true + echo "inet address present: $_addr" >> $_logfile + fi + ((count++)) + done +fi + +for dir in $(ls /mnt/$USER) ; do + MOUNT_POINT=/mnt/$USER/$dir + SHARE=$dir + + [ ! -d $MOUNT_POINT ] && continue + + if ! mount | grep $MOUNT_POINT > /dev/null ; then + echo "Going to mount share '${SHARE}' .." >> $_logfile + if [ -x /usr/bin/smb4k_mount ]; then + ## - Ubuntu <= 12.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID,vers=$VERSION \ + sudo /usr/bin/smb4k_mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$_UID,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + else + ## - Ubuntu Version >= 14.04 + if [[ "$VERSION" = "1.0" ]]; then + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,vers=1.0 \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + else + #sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,cifsacl,uid=$USER,sec=${SEC},vers=$VERSION \ + sudo /bin/mount -o user=$USER,password=$PASSWORD,iocharset=utf8,uid=$USER,gid=$_GID \ + -n -t cifs //$SERVER/$SHARE $MOUNT_POINT >> $_logfile 2>&1 + fi + fi + else + echo "mount point $MOUNT_POINT already exists. nothing left to do.." >> $_logfile + fi + +done + diff --git a/group_vars/sprachenatelier.yml b/group_vars/sprachenatelier.yml index b8f45e2..c6e77e6 100644 --- a/group_vars/sprachenatelier.yml +++ b/group_vars/sprachenatelier.yml @@ -134,6 +134,7 @@ nis_groups: # - name: simone nis_user: + - name: chris groups: - intern diff --git a/roles/common/tasks/nis-user-systemfiles.yml b/roles/common/tasks/nis-user-systemfiles.yml index 2a06d91..bb899ae 100644 --- a/roles/common/tasks/nis-user-systemfiles.yml +++ b/roles/common/tasks/nis-user-systemfiles.yml @@ -52,37 +52,39 @@ - profile -# 1) Für jeden NIS-User prüfen, ob eine lokale _profile existiert -- name: (nis-user-systemfiles.yml) stat user _profile +# 1) Für jeden NIS-User prüfen, ob eine lokale _profile.j2 existiert +- name: (nis-user-systemfiles.yml) stat user _profile.j2 ansible.builtin.stat: - path: "{{ inventory_dir }}/files/{{ nis_domain }}/homedirs/{{ item.name }}/_profile" + path: "{{ inventory_dir }}/files/{{ nis_domain }}/homedirs/DEFAULT/_profile.j2" delegate_to: localhost become: false loop: "{{ nis_user }}" - register: profile_stats + register: profile_template_stats loop_control: label: "{{ item.name }}" -# 2) Falls NIS-User _profile vorhanden, kopieren -- name: (nis-user-systemfiles.yml) copy .profile if it exists - ansible.builtin.copy: - src: "{{ inventory_dir }}/files/{{ nis_domain }}/homedirs/{{ user.name }}/_profile" +# 2) Falls _profile.j2 vorhanden, .profile aus Template rendern +- name: (nis-user-systemfiles.yml) template .profile if _profile.j2 exists + ansible.builtin.template: + src: "{{ inventory_dir }}/files/{{ nis_domain }}/homedirs/DEFAULT/_profile.j2" dest: "~{{ user.name }}/.profile" owner: "{{ user.name }}" group: "{{ user.name }}" mode: "0644" become: true - loop: "{{ nis_user | zip(profile_stats.results) | list }}" + loop: "{{ nis_user | zip(profile_template_stats.results) | list }}" loop_control: label: "{{ user.name }}" - when: + when: - stat_result.stat.exists | bool vars: - user: "{{ item.0 }}" + user: "{{ item.0 }}" stat_result: "{{ item.1 }}" tags: [bash] + + # -- # Copy .bashrc # ---