Last active
August 29, 2015 14:00
-
-
Save aleks-mariusz/a327bb1017ca3ce68bc2 to your computer and use it in GitHub Desktop.
May 4 2006 - You'll come to a point where the tools you're familiar/most comfortable with just aren't enough and you have to learn new ones.. Here i had to configure several dozen APC power strips.. fortunately they had rs232 serial ports, and i had my powerbook with a kensington usb-serial adapter (the one not based on the prolific pl2302 chips…
This file contains 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
#!/usr/local/bin/kermit.real + | |
# Usage: apc-config [ hostname ] [ ip address ] | |
# | |
# written in spring 2006.. | |
# | |
# .file := \fcontents(\%1) # Eval one level deep in case of backslashes | |
#} else while not def file { # Prompt for it if not given | |
# ask file " Log file name: " | |
#} | |
set modem type none # No modem is involved | |
set flow-control none # Or Xon/Xoff, or None | |
set carrier-watch off # Uncomment if there is no Carrier signal | |
set parity none # Or Even, Mark, Space, or Odd as needed | |
set port /dev/cu.KeySerial1 # Or whatever port you are using | |
if fail { # Check that port was obtained | |
exit 1 \m(port): \v(setlinemsg) | |
} | |
set speed 9600 # Or whatever speed is needed | |
## can only take up to 9 args on the command line, so we will hard code the least changed ones here | |
.domainname := nydc.fxcorp.prv | |
.dnsfirst := 10.60.4.20 | |
.dnssecond := 10.60.4.10 | |
.location := NYDC | |
.defaultPortName := empty | |
if = \v(argc) 9 { | |
.numoutlets := \fcontents(\%1) | |
.username := \fcontents(\%2) | |
.password := \fcontents(\%3) | |
.ipaddress := \fcontents(\%4) | |
.subnetmask := \fcontents(\%5) | |
.defgateway := \fcontents(\%6) | |
.hostname := \fcontents(\%7) | |
.newpasswd := \fcontents(\%8) | |
} else { | |
echo "To run script non-interactively specify the following parameters on command line:" | |
echo | |
echo \%0 [num ports] [login] [passwd] [ip] [subnet] [gateway] [hostname] [new passwd] | |
echo | |
ask numoutlets "How many outlets does this APC have? " | |
ask username "What username should I log in as? " | |
askq password "What password should I use? " | |
echo "What will be this APC's.." | |
ask ipaddress " ..IP address? " | |
ask subnetmask " ..subnet mask? " | |
ask defgateway " ..default gateway? " | |
ask hostname " ..hostname? " | |
# ask domainname " ..domain name? " | |
# ask dnsfirst " ..primary DNS server? " | |
# ask dnssecond " ..secondary DNS server? " | |
# ask location " ..datacenter location? " | |
askq newpasswd " ..new password? " | |
} | |
echo | |
echo Now configuring APC with the following parameters: | |
echo numoutlets = \m(numOutlets) | |
echo username = \m(username) | |
echo password = \m(password) | |
echo ipaddress = \m(ipaddress) | |
echo subnetmask = \m(subnetmask) | |
echo defgateway = \m(defgateway) | |
echo hostname = \m(hostname) | |
echo domainname = \m(domainname) | |
echo dnsfirst = \m(dnsfirst) | |
echo dnssecond = \m(dnssecond) | |
echo location = \m(location) | |
echo newpasswd = \m(newpasswd) | |
echo | |
echo | |
set input echo off | |
clear input | |
echo "Now logging in.. " | |
output \13 | |
output \13 | |
output \13 | |
input 2 "User Name :" | |
if fail { # Catch i/o errors | |
exit 1 "Did not get login prompt!" | |
} | |
output \m(username)\13 | |
output \m(password)\13 | |
input 10 "Control Console" | |
if fail { | |
exit 1 "Did not get menu after login!" | |
} | |
.currNum ::= 1 | |
#while <= \m(currNum) \m(numoutlets) { | |
# | |
# output 1\13 | |
# input 10 "> " | |
# if fail { | |
# exit 1 "Did not get into Device Manager" | |
# } | |
# | |
# sleep 1 | |
# output 3\13\13 | |
# input 10 "> " | |
# if fail { | |
# exit 1 "Did not get into Outlet Control/Config" | |
# } | |
# | |
# echo " Setting port \m(currNum)'s name to '\m(defaultPortName)'" | |
# input 10 "> " | |
# if fail { | |
# exit 1 "Timed out waiting for prompt on port \m(currNum).. " | |
# } | |
# | |
# output \m(currNum)\13 | |
# output 2\13 | |
# | |
# output 1\13 | |
# input 10 "Outlet Name :" | |
# if fail { | |
# exit 1 "Could not set port \m(currNum) to \m(defaultPortName).. " | |
# } | |
# output \m(defaultPortName)\13 | |
# input 10 "> " | |
# if fail { | |
# exit 1 "Timed out waiting for prompt on port \m(currNum).. " | |
# } | |
# | |
# output 5\13 | |
# input 10 "> " | |
# if fail { | |
# exit 1 "Timed out waiting for parent menu after setting port \m(currNum).. " | |
# } | |
# | |
# output \3\3\3\3 | |
# input 10 "Control Console" | |
# | |
# .currNum ::= \m(currNum)+1 | |
#} | |
echo " Entering Network Menu.. " | |
output 2\13 | |
echo " Entering TCP/IP Menu.. " | |
output 1\13 | |
echo " Selecting to use Manual Configuration.. " | |
output 1\13 | |
output 4\13 | |
echo " Setting IP.. " | |
output 1\13 | |
input 10 "System IP :" | |
if fail { | |
exit 1 "Did not get prompt for entering system IP" | |
} | |
output \m(ipaddress)\13 | |
echo " Setting Subnet Mask.. " | |
output 2\13 | |
input 10 "Subnet Mask :" | |
if fail { | |
exit 1 "Did not get prompt for entering subnet mask" | |
} | |
output \m(subnetmask)\13 | |
echo " Setting Default Gateway.. " | |
output 3\13 | |
input 10 "Default Gateway :" | |
if fail { | |
exit 1 "Did not get prompt for entering default gateway" | |
} | |
output \m(defgateway)\13 | |
echo " Saving changes so far.. " | |
output 4\13 | |
output 4\13 | |
sleep 2 | |
output \3\3\3 | |
input 10 "Control Console" | |
echo " Entering TCP/IP Advanced Menu.. " | |
output 2\13 | |
output 1\13 | |
output 5\13 | |
echo " Setting Hostname.. " | |
output 1\13 | |
input 10 "Host Name :" | |
if fail { | |
exit 1 "Did not get prompt for entering host name" | |
} | |
output \m(hostname)\13 | |
echo " Settinm Domain.. " | |
output 2\13 | |
input 10 "Domain Name :" | |
if fail { | |
exit 1 "Did not get prompt for entering domain name" | |
} | |
output \m(domainname)\13 | |
echo " Setting Media Auto-Negotiation.. " | |
output 3\13 | |
output 1\13 | |
echo " Saving changes so far.. " | |
output 4\13 | |
sleep 2 | |
output \3\3\3 | |
input 10 "Control Console" | |
echo " Entering DNS menu.." | |
output 2\13 | |
output 2\13 | |
echo " Setting Primary DNS.. " | |
output 1\13 | |
input 10 "Primary DNS Server IP :" | |
if fail { | |
exit 1 "Did not get prompt for primary DNS" | |
} | |
output \m(dnsfirst)\13 | |
echo " Setting Secondary DNS.. " | |
output 2\13 | |
input 10 "Secondary DNS Server IP :" | |
if fail { | |
exit 1 "Did not get prompt for Secondary DNS" | |
} | |
output \m(dnssecond)\13 | |
echo " Disabling Reverse DNS Lookups.. " | |
output 3\13 | |
output 1\13 | |
echo " Saving changes so far.. " | |
output 4\13 | |
output \3\3\3 | |
echo " Entering FTP menu.. " | |
output 2\13 | |
output 4\13 | |
input 32 "------- FTP Server --------" | |
if fail { | |
exit 1 "Did not reach the FTP Menu" | |
} | |
output 1\13 | |
echo " Disabling FTPd.. " | |
output 1\13 | |
echo " Saving changes so far.. " | |
output 3\13 | |
output \3\3\3 | |
echo " Entering Telnet/SSH menu.. " | |
output 2\13 | |
output 5\13 | |
input 32 "------- Telnet/SSH ------------" | |
if fail { | |
exit 1 "Did not reach the Telnet/SSH Menu" | |
} | |
output 1\13 | |
echo " Enabling Logging capability.." | |
output 2\13 | |
output 2\13 | |
echo " Allowing only SSHv2.." | |
output 4\13 | |
echo " Saving changes so far.. " | |
output 6\13 | |
output \13 | |
echo " Confirming Export License.." | |
output YES\13 | |
output \3\3\3 | |
echo " Entering Web/SSL/TLS menu.. " | |
output 2\13 | |
output 6\13 | |
input 32 "------- Web/SSL/TLS --------------" | |
if fail { | |
exit 1 "Did not reach the Web/SSL/TLS Menu" | |
} | |
output 1\13 | |
echo " Enabling Web Access.. " | |
output 2\13 | |
echo " Enabling TLS abilities.. " | |
output 2\13 | |
output 2\13 | |
echo " Saving changes so far.. " | |
output 6\13 | |
output \13 | |
output YES\13 | |
output \3\3\3 | |
echo " Entering WAP menu.. " | |
output 2\13 | |
output 7\13 | |
input 32 "------- WAP ----------" | |
if fail { | |
exit 1 "Did not reach the WAP Menu" | |
} | |
output 1\13 | |
echo " Disabling WAP Access.. " | |
output 1\13 | |
echo " Saving changes so far.. " | |
output 2\13 | |
output \3 | |
output \3\3\3 | |
echo " Entering SNMP Menu" | |
output 2\13 | |
output 8\13 | |
input 32 "------- SNMP ---------" | |
if fail { | |
exit 1 "Did not reach the SNMP Menu" | |
} | |
output 3\13 | |
output 2\13 | |
echo " Disabling private Write community.. " | |
output 3\13 | |
echo " Saving changes so far.. " | |
output 4\13 | |
output \3\3 | |
output \3\3\3 | |
echo " Entering ISX Protocol menu.. " | |
output 2\13 | |
output 11\13 | |
input 32 "------- ISX Protocol ----------" | |
if fail { | |
exit 1 "Did not reach the ISX Menu" | |
} | |
output 1\13 | |
echo " Enabling ISX Protocol.. " | |
output 2\13 | |
echo " Saving changes so far.. " | |
output 2\13 | |
output \3 | |
output \3\3\3 | |
echo " Setting APC's Name.. " | |
output 3\13 | |
output 2\13 | |
output 1\13 | |
input 60 "Name :" | |
if fail { | |
exit 1 "Did not get prompt for Name" | |
} | |
output \m(hostname)\13 | |
echo " ...and Location.. " | |
output 3\13 | |
input 10 "Location :" | |
if fail { | |
exit 1 "Did not get prompt for Location" | |
} | |
output \m(location)\13 | |
output 4\13 | |
output \3\3\3 | |
echo " Setting APC's NTP.. " | |
output 3\13 | |
output 3\13 | |
input 32 "------- Date/Time -----------" | |
if fail { | |
exit 1 "Did not reach the Date/Time Menu" | |
} | |
output 2\13 | |
echo " Setting primary NTP server.." | |
output 1\13 | |
input 10 "Primary NTP Server :" | |
output \m(dnssecond)\13 | |
echo " Setting secondary NTP server.." | |
output 2\13 | |
input 10 "Secondary NTP Server :" | |
output \m(dnsfirst)\13 | |
echo " Enabling NTP client.. " | |
output 5\13 | |
output 2\13 | |
echo " Saving changes so far.. " | |
output 6\13 | |
sleep 2 | |
output \3\3\3 | |
echo "Setting APC's new device manager password.. " | |
output 3\13 | |
output 1\13 | |
input 32 "------- User Manager ----------" | |
if fail { | |
exit 1 "Did not reach the User Mgmt Menu" | |
} | |
output 2\13 | |
input 60 "Enter current Administrator password :" | |
output \m(password)\13 | |
input 10 "<ENTER> to skip :" | |
output \13 | |
input 10 "<ENTER> to skip :" | |
output \m(newpasswd)\13 | |
input 10 "Confirm new Administrator password :" | |
output \m(newpasswd)\13 | |
output \13 | |
output 5\13 | |
sleep 2 | |
output \3\3\3 | |
input 32 "Control Console" | |
echo "Setting APC's new administrative password.. " | |
output 3\13 | |
output 1\13 | |
input 32 "------- User Manager ----------" | |
if fail { | |
exit 1 "Did not reach the User Mgmt Menu" | |
} | |
output 1\13 | |
input 60 "Enter current Administrator password :" | |
output \m(password)\13 | |
input 10 "<ENTER> to skip :" | |
output \13 | |
input 10 "<ENTER> to skip :" | |
output \m(newpasswd)\13 | |
input 10 "Confirm new Administrator password :" | |
output \m(newpasswd)\13 | |
output \13 | |
output 5\13 | |
output \3\3\3\3 | |
echo "Logging out.. " | |
output 4\13 | |
input -1 "You are now in passthru mode." | |
if fail { | |
exit 1 "Problem logging out.. " | |
} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment