Changes between Version 1 and Version 2 of solaris


Ignore:
Timestamp:
Apr 16, 2018, 8:21:36 AM (5 months ago)
Author:
joerg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • solaris

    v1 v2  
    297297pfexec zoneadm -z $object reboot
    298298}}}
     299
     300== Enable User
     301
     302{{{
     303#!/bin/bash
     304
     305if test -e /var/ldap/ldap_client_file
     306then
     307  LDAP_HOST=$(pfexec grep NS_LDAP_SERVERS /var/ldap/ldap_client_file|cut -f2 -d'='|cut -f1 -d','|sed -e 's/ //g')
     308else
     309  LDAP_HOST="$(ifconfig -a|tail -1|cut -f2 -d' '|cut -d'.' -f1-2|sed -e 's/ //g').0.99"
     310fi
     311
     312DEFGID=1500
     313
     314me="$(id|cut -d'(' -f2|cut -d')' -f1)"
     315
     316
     317dir=$(ldapsearch  -h $LDAP_HOST -b dc=pribas,dc=com uid=$1 homeDirectory|grep homeDirectory|cut -d ' ' -f2)
     318gid=$(ldapsearch  -h $LDAP_HOST -b dc=pribas,dc=com uid=$1 gidNumber|grep gidNumber|cut -d ' ' -f2)
     319
     320test -z $dir && echo "User does not exist or is not configured for unix account - home directory missing" && exit 1
     321test -z $gid && echo "User does not exist or is not configured for unix account - group id missing" && gid=$DEFGID
     322
     323pfexec mkdir -p $dir/.ssh
     324pfexec chown $me $dir/.ssh
     325key="$(ldapsearch  -h $LDAP_HOST -b dc=pribas,dc=com  -T -B -F ' ' uid=$1 userCertificate|grep userCertificate|cut -d' ' -f2-)"
     326test -z "$key" && echo "User does not exist or no certificate is stored in ldap"
     327echo "$key"> $dir/.ssh/authorized_keys
     328pfexec chown -R $1:$gid $dir
     329}}}