The purpose of this is to simplify some of the daily routine for most system admins.
These scripts go through a couple of the basics that we run into every day.. “My computer has a virus” “I forgot my email password” “X program isn’t working.
All of the commands are executed in the background using the WMI toolkit in linux. They have been extensively tested using winexe 0.90 on Ubuntu 8.04.
Let me know what you think…
# For Daysol, Inc internal purposes only. # DO NOT DISTRIBUTE. # Author: Sean Sturts # Version 0.1 # Confirmed working: 08/06/2010 16:40 # Syntax: ./mgmt.sh # This script will allow an administrator to rename a restricted user # profile or reset a Zimbra email password. # This script depends on the WMI toolkit (apt-get install wmi-client) or it can be # build from source. choice=5 # Print the selection menu echo "1. Rename User Profile" echo "2. Change Zimbra Password" echo "3. Turn off XP Firewall" echo "4. Exit" echo -n "Please select an action [1-4]: " while [ $choice -eq 5 ] ; do read choice # Choice 1. # This section of the script connects to the user pc using winexe and renames the # problematic profile. # The user name must be correct and the extension must be unique. if [ $choice -eq 1 ]; then echo "Please enter the domain admin password [ENTER]: (text will not be displayed.)" stty -echo read PASSWORD stty echo echo echo -n "Please enter the username [ENTER]: " read USERNAME echo echo -n "Please enter a unique extension [ENTER]: " read EXTENSION echo echo -n "Please enter the client IP address [ENTER]: " read HOST_IP { winexe -U "Domain\username%$PASSWORD" //$HOST_IP \ cmd <<EOF & shutdown -r -f -t 60 -c "The PC will be restarted in 60 seconds. The virus removal process may take up to 7 minutes" exit EOF } { sleep 8 echo echo echo echo Press [ENTER] when the computer has restarted. read null } { winexe -U "Domain\username%$PASSWORD" //$HOST_IP \ cmd <<EOF & cd \docu* rename $USERNAME $USERNAME.$EXTENSION EOF } { sleep 5 echo echo echo echo Press [ENTER] after the user has logged in. read null } { winexe -U "Domain\username%$PASSWORD" //$HOST_IP \ cmd <<EOF & cd \docu* copy /Y $USERNAME.$EXTENSION\desktop $USERNAME\desktop\*.* copy /Y $USERNAME.$EXTENSION\favorites $USERNAME\favorites\*.* copy /Y $USERNAME.$EXTENSION\mydocu~1 $USERNAME\mydocu~1\*.* shutdown -r -f -t 15 -c "There is really no need for this restart but why not..." EOF } { sleep 20 echo echo echo echo Process is complete. } break else # Choice 2 # This section of the script connects to the Zimbra server using plink. # It executes a remote script for administrative prompts. if [ $choice -eq 2 ]; then { plink -l root -ssh 10.2.0.103 /root/./zimbrapwchange.sh } else # Choice 3 # This script will turn off the Windows XP firewall and add port exceptions. # You must be able to ping the PC for this to work. This does not work on # SP3. if [ $choice -eq 3 ]; then { echo "Please enter the domain admin password [ENTER]: (text will not be displayed.)" stty -echo read PASSWORD stty echo echo echo -n "Please enter the client IP address [ENTER]: " read HOST_IP winexe -U "Domain\username%$PASSWORD" //$HOST_IP \ cmd <<EOF & netsh firewall add portopening all 5900 VNC_5900 netsh firewall add portopening all 1000 Random_name netsh firewall add portopening all 1001 Another_port # This portion of the script will remove the domain users group from the Administrators # group. This is not necessary. net localgroup "administrators" "Domain\domain users" /delete exit echo "The process is complete." EOF } break else # Choice 4 # Exit the script without making an administrative selection. if [ $choice -eq 4 ]; then { break } { # Print the selection menu echo "1. Rename User Profile" echo "2. Change Zimbra Password" echo "3. Turn off XP Firewall" echo "4. Exit" echo -n "Please select an action [1-4]: " choice=5 } fi fi fi fi done ############################################################### ############################################################### This is a seperate script that is accessed by the above script. It is seperate for ease of use.. # For Daysol, Inc internal purposes only. # DO NOT DISTRIBUTE. # Author: Sean Sturts # Version 0.2.1 # Date of revision: 8/5/2010 09:05 # Confirmed working: 8/5/2010 09:15 # Syntax: ./zimbrapwchange.sh # The purpose of this script is to automate changing user passwords in Zimbra OSS. # This section of the script prompts for user input. echo Please enter the Username and Domain. [ENTER:] read USERNAME echo Please confirm the Username and Domain. [ENTER:] read CONFIRM ## Commented for static password changes. # echo Please enter the temporary password. [ENTER:] # read PASSWORD ## Above will be removed later. # This section of the script confirms the Username. if [ $USERNAME = $CONFIRM ]; then echo The username was confirmed. Their password will be changed. # This section changes the users password su - zimbra /opt/zimbra/bin/zmprov sp $USERNAME 123456 # This section requires the user to change their password on first login. su - zimbra /opt/zimbra/bin/zmprov ma $USERNAME zimbraPasswordMustChange TRUE # Exiting script & terminating SSH session else echo The username was not confirmed. Terminating. exit exit exit fi exit exit exit |
Leave a Reply