Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/expect
- #������ �������� ��������� ������������ �� ���������. ���� ����� �� ������� ���������� ������������)
- log_user 0
- set controlc /x03
- set adminacc "admin"
- set adminpass "dafyxas"
- set guestacc "acc"
- set guestpass "kozaryv"
- set snmphost "172.19.1.15"
- proc zyxel_setup { adminacc adminpass guestacc guestpass snmphost } {
- send_user "This is Zyxel.\r\n"
- send "$adminacc\r"
- expect "Password:"
- send "$adminpass\r"
- expect "#"
- send "config\r"
- expect "(config)#"
- #���������� �������
- send "timesync ntp\r"
- expect "(config)#"
- send "timesync server 172.19.1.15\r"
- expect "(config)#"
- send "time timezone 1000\r"
- expect "(config)#"
- send "time daylight-saving-time\r"
- expect "(config)#"
- send "time daylight-saving start-date last sunday march 3\r"
- expect "(config)#"
- send "time daylight-saving end-date last sunday october 3\r"
- send_user "Timesync configured\r\n"
- expect "(config)#"
- #�������
- send "logins username $guestacc password $guestpass\r"
- send_user "$guestacc account created\r\n"
- #������ � ����������� (���������)
- expect "(config)#"
- send "remote-management 2 start-addr 172.19.0.0 end-addr 172.19.1.254 service icmp telnet http\r"
- expect "(config)#"
- send "remote-management 2\r"
- expect "(config)#"
- send "remote-management 3 start-addr 172.20.0.0 end-addr 172.20.0.254 service icmp telnet http\r"
- expect "(config)#"
- send "remote-management 3\r"
- expect "(config)#"
- send "remote-management 4 start-addr 172.19.33.252 end-addr 172.19.33.252 service icmp telnet http\r"
- expect "(config)#"
- send "remote-management 4\r"
- expect "(config)#"
- send "no remote-management 1 service http https snmp ssh telnet ftp\r"
- expect "(config)#"
- send "remote-management 1\r"
- send_user "trusted hosts added\r\n"
- expect "(config)#"
- send "exit\r"
- expect "#"
- send "write memory\r"
- send_user "Switch saved\r\n"
- expect "#"
- send "logout\r"
- }
- proc dlink_setup { adminacc adminpass guestacc guestpass snmphost } {
- send_user "Dlink Switch. Starting setup.\r\n"
- send "$adminacc\r"
- expect "PassWord:"
- send "$adminpass\r"
- expect "#"
- #�������� ������� (��� ���������� ��������� ����� ������� ��� ���� ���� �����-�����). ��������� �� ��� �������.
- #��������� �������
- send "create account admin $adminacc\r"
- expect "Enter a case-sensitive new password:" {
- send_user "$adminacc account not exist. Creating.\r\n"
- send "$adminpass\r"
- expect "Enter the new password again for confirmation:"
- send "$adminpass\r"
- expect "Success"
- send_user "$adminacc account created.\r\n" } \
- "The specified user already exists. Enter a unique username." { send_user "$adminacc account already exist.\r\n" }
- expect "#"
- #������� ����
- send "create account user $guestacc\r"
- expect "Enter a case-sensitive new password:" {
- send_user "$guestacc account not exist. Creating.\r\n"
- send "$guestpass\r"
- expect "Enter the new password again for confirmation:"
- send "$guestpass\r"
- expect "Success"
- send_user "$guestacc account created.\r\n" } \
- "The specified user already exists. Enter a unique username." {
- #� ��� ���� ��� ���� ��� ��������� - ������ � �������� ������ (���� ���� � ���� ������� ����� �� ����� � �������� ������ ��� �����)
- send_user "$guestacc user already exist. Recreating.\r\n"
- expect "#"
- send "delete account $guestacc\r"
- expect "Success" { send_user "$guestacc deleted\r\n" }
- expect "#"
- send "create account user $guestacc\r"
- expect "Enter a case-sensitive new password:"
- send "$guestpass\r"
- expect "Enter the new password again for confirmation:"
- send "$guestpass\r"
- expect "Success" { send_user "$guestacc account created.\r\n"} }
- expect "#"
- #�������� ���������� ������������� �������� ��������
- #������ ������ ��� � �����
- send "delete trusted_host all\r"
- expect "Success" { send_user "trusted host list cleared\r\n" }
- expect "#"
- send "create trusted_host network 172.19.1.0/24\r"
- expect "Success" { send_user "trust for network 172.19.1.0/24 added\r\n" }
- expect "#"
- send "create trusted_host network 172.19.0.0/24\r"
- expect "Success" { send_user "trust for network 172.19.0.0/24 added\r\n" }
- expect "#"
- send "create trusted_host network 172.18.0.0/24\r"
- expect "Success" { send_user "trust for network 172.18.0.0/24 added\r\n" }
- expect "#"
- send "create trusted_host network 172.20.0.0/24\r"
- expect "Success" { send_user "trust for network 172.20.0.0/24 added\r\n" }
- expect "#"
- send "create trusted_host 172.19.33.252\r"
- expect "Success" { send_user "paha's host added to trusted =)\r\n" }
- expect "#"
- #��������� ����� - ��������� �������
- send "enable sntp\r"
- expect "Success" { send_user "sntp enabled\r\n" }
- expect "#"
- send "config sntp primary 172.19.1.15\r"
- expect "Success" { send_user "sntp primary server set to 172.19.1.15\r\n" }
- expect "#"
- send "config dst repeating s_week last s_mth 3 s_day sun s_time 03:00 e_week last e_mth 10 e_day sun e_time 03:00 offset 60\r"
- expect "Success" { send_user "daylight saving time configured\r\n" }
- expect "#"
- send "config time_zone operator + hour 10 min 0\r"
- expect "Success" { send_user "time zone configured\r\n" }
- expect "#"
- send "save all\r"
- send_user "Switch saved\r\n"
- expect "#"
- send "logout\r"
- }
- spawn telnet $argv
- send_user "#############################\r\n"
- send_user "$argv starting...\r\n"
- expect "UserName:" { dlink_setup $adminacc $adminpass $guestacc $guestpass $snmphost } \
- "User name" { zyxel_setup $adminacc $adminpass $guestacc $guestpass $snmphost } \
- { send_user "What is $argv? Stop.\r\n" }
- send_user "$argv end.\r\n"
- send_user "#############################\r\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement