diff options
Diffstat (limited to 'templates')
36 files changed, 242 insertions, 2 deletions
diff --git a/templates/add/node.def b/templates/add/node.def new file mode 100644 index 0000000..39ff67a --- /dev/null +++ b/templates/add/node.def @@ -0,0 +1 @@ +help: Add an object to a service diff --git a/templates/add/raid/node.def b/templates/add/raid/node.def new file mode 100644 index 0000000..26cc4a3 --- /dev/null +++ b/templates/add/raid/node.def @@ -0,0 +1 @@ +help: Add a RAID set element diff --git a/templates/add/raid/node.tag/member/node.def b/templates/add/raid/node.tag/member/node.def new file mode 100644 index 0000000..efa1d45 --- /dev/null +++ b/templates/add/raid/node.tag/member/node.def @@ -0,0 +1 @@ +help: Add a member to a RAID set
\ No newline at end of file diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def new file mode 100644 index 0000000..60eff63 --- /dev/null +++ b/templates/add/raid/node.tag/member/node.tag/node.def @@ -0,0 +1,38 @@ +help: Name of RAID set member to add + +allowed: + raid_set=${COMP_WORDS[2]} + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + membership=`echo $membership | sed -e 's/(F)//g'` + partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"` + for member in $membership; do + partitions=`echo $partitions | sed -e s/$member//g` + done + partitions=`echo $partitions | sed -e 's/md[0-9]*//g'` + echo "$partitions" + +run: + raid_set=$3 + member_to_add=$5 + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + is_in=`echo $membership | grep $member_to_add` + + partitions=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep "[0-9]"` + partitions=`echo $partitions | sed -e 's/md[0-9]*//g'` + valid_partition=`echo $partitions | grep $member_to_add` + + if [ -z "$membership" ]; then + echo "$raid_set is not a RAID set" + elif [ -n "$is_in" ]; then + echo "$member_to_add is already a member of RAID set $raid_set" + echo "actual members are: $membership" + elif [ -z "$valid_partition" ]; then + echo "$member_to_add is not a valid disk partition" + else + echo "adding member $member_to_add to RAID set $raid_set" + mdadm /dev/$raid_set --add /dev/$member_to_add + if [ $? -ne 0 ]; then + echo "Unable to add member to RAID set" + fi + fi + diff --git a/templates/add/raid/node.tag/node.def b/templates/add/raid/node.tag/node.def new file mode 100644 index 0000000..e0ae4d9 --- /dev/null +++ b/templates/add/raid/node.tag/node.def @@ -0,0 +1,6 @@ +help: Name of RAID set to add object to + +allowed: + local -a array ; + array=`cat /proc/partitions | grep md | awk '{ print $4 }'` + echo -n $array diff --git a/templates/clear/dns/forwarding/all/node.def b/templates/clear/dns/forwarding/all/node.def new file mode 100644 index 0000000..b439b78 --- /dev/null +++ b/templates/clear/dns/forwarding/all/node.def @@ -0,0 +1,8 @@ +help: Clear DNS forwarding cache and counters +run: + if ps ax | grep dnsmasq | grep -v grep > /dev/null + then + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dns-forwarding.pl --clear-all + else + echo "DNS forwarding not configured" + fi diff --git a/templates/clear/dns/forwarding/cache/node.def b/templates/clear/dns/forwarding/cache/node.def new file mode 100644 index 0000000..8a5f8cc --- /dev/null +++ b/templates/clear/dns/forwarding/cache/node.def @@ -0,0 +1,8 @@ +help: Clear DNS forwarding cache +run: + if ps ax | grep dnsmasq | grep -v grep > /dev/null + then + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dns-forwarding.pl --clear-cache + else + echo "DNS forwarding not configured" + fi diff --git a/templates/clear/dns/forwarding/node.def b/templates/clear/dns/forwarding/node.def new file mode 100644 index 0000000..3cc321c --- /dev/null +++ b/templates/clear/dns/forwarding/node.def @@ -0,0 +1 @@ +help: Clear DNS forwarding variables diff --git a/templates/clear/dns/node.def b/templates/clear/dns/node.def new file mode 100644 index 0000000..bca966e --- /dev/null +++ b/templates/clear/dns/node.def @@ -0,0 +1 @@ +help: Clear Domain Name Server (DNS) variables diff --git a/templates/format/disk/node.def b/templates/format/disk/node.def new file mode 100644 index 0000000..664804b --- /dev/null +++ b/templates/format/disk/node.def @@ -0,0 +1 @@ +help: Format a disk drive
\ No newline at end of file diff --git a/templates/format/disk/node.tag/like/node.def b/templates/format/disk/node.tag/like/node.def new file mode 100644 index 0000000..99f73b1 --- /dev/null +++ b/templates/format/disk/node.tag/like/node.def @@ -0,0 +1 @@ +help: Format this disk the same as another disk
\ No newline at end of file diff --git a/templates/format/disk/node.tag/like/node.tag/node.def b/templates/format/disk/node.tag/like/node.tag/node.def new file mode 100644 index 0000000..8927dc8 --- /dev/null +++ b/templates/format/disk/node.tag/like/node.tag/node.def @@ -0,0 +1,59 @@ +help: Name of disk drive to partition it like + +allowed: + local -a disks ; + proto_disk=${COMP_WORDS[2]} + disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` + disks=`echo $disks | sed -e s/$proto_disk//g` + echo -n $disks + +run: + proto_disk=$5 + format_disk=$3 + backup_dir=/var/log/vyatta + eligible_format_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` + eligible_proto_disks=`echo $eligible_format_disks | sed -e s/$format_disk//g` + proto_eligible=`echo $eligible_proto_disks | grep $proto_disk` + format_eligible=`echo $eligible_format_disks | grep $format_disk` + busy_check=`sfdisk -R /dev/$format_disk 2>&1` + + if [ $proto_disk = $format_disk ]; then + echo "The two disk drives must be different." + elif [ ! -b /dev/$proto_disk ]; then + echo "Device /dev/$proto_disk does not exist" + elif [ ! -b /dev/$format_disk ]; then + echo "Device /dev/$format_disk does not exist" + elif [ -z "$format_eligible" ]; then + echo "Device $format_disk can not be formatted" + elif [ -z "$proto_eligible" ]; then + echo "Device $proto_disk can not be used as a prototype for $format_disk" + elif [ -n "$busy_check" ]; then + echo "Disk device $format_disk is busy. Can't format it now." + else + echo "This will re-format disk $format_disk so that it has the same disk" + echo "partion sizes and offsets as $proto_disk. This will not copy" + echo "data from $proto_disk to $format_disk. But this will erase all" + echo "data on $format_disk." + echo + echo -n "Do you wish to proceed (yes, NO)? " + read response + if [ "$response" = "yes" ]; then + echo "OK. Re-formating disk drive $format_disk..." + echo "Making backup copy of partitions..." + sfdisk -d /dev/$format_disk > $backup_dir/backup_$format_disk.`date +%F-%R` + sleep 1 + partitions=`cat /proc/partitions | grep $format_disk'[0-9]' | awk '{ print $4 }' | sed 's/[a-z]//g'` + if [ -n "$partitions" ]; then + echo -n "Deleting old partitions..." + for part in $partitions ; do + parted /dev/$format_disk rm $part + done + echo "" + fi + echo "Creating new partitions on $format_disk based on $proto_disk..." + sfdisk -d /dev/$proto_disk | sfdisk --force /dev/$format_disk + echo "Done." + else + echo "OK. Disk drive $format_drive will not be re-formated." + fi + fi
\ No newline at end of file diff --git a/templates/format/disk/node.tag/node.def b/templates/format/disk/node.tag/node.def new file mode 100644 index 0000000..2b77c5b --- /dev/null +++ b/templates/format/disk/node.tag/node.def @@ -0,0 +1,6 @@ +help: Disk drive name + +allowed: + local -a array ; + array=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` + echo -n $array diff --git a/templates/format/node.def b/templates/format/node.def new file mode 100644 index 0000000..edb71bd --- /dev/null +++ b/templates/format/node.def @@ -0,0 +1 @@ +help: Format a device
\ No newline at end of file diff --git a/templates/release/dhcp/interface/node.tag/node.def b/templates/release/dhcp/interface/node.tag/node.def index 2fadea2..85773b6 100644 --- a/templates/release/dhcp/interface/node.tag/node.def +++ b/templates/release/dhcp/interface/node.tag/node.def @@ -1,7 +1,7 @@ help: Release DHCP IP address lease for specified interface allowed: local -a array ; - array=( /var/lib/dhcp3/eth* ) ; + array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* ) ; echo -n ${array[@]##*/} run: diff --git a/templates/remove/node.def b/templates/remove/node.def new file mode 100644 index 0000000..387e0d2 --- /dev/null +++ b/templates/remove/node.def @@ -0,0 +1 @@ +help: Remove an object from service diff --git a/templates/remove/raid/node.def b/templates/remove/raid/node.def new file mode 100644 index 0000000..2700b93 --- /dev/null +++ b/templates/remove/raid/node.def @@ -0,0 +1 @@ +help: Remove a RAID set element diff --git a/templates/remove/raid/node.tag/member/node.def b/templates/remove/raid/node.tag/member/node.def new file mode 100644 index 0000000..6af665d --- /dev/null +++ b/templates/remove/raid/node.tag/member/node.def @@ -0,0 +1 @@ +help: Remove a member of a RAID set
\ No newline at end of file diff --git a/templates/remove/raid/node.tag/member/node.tag/node.def b/templates/remove/raid/node.tag/member/node.tag/node.def new file mode 100644 index 0000000..d384fd3 --- /dev/null +++ b/templates/remove/raid/node.tag/member/node.tag/node.def @@ -0,0 +1,35 @@ +help: Name of RAID set member to remove + +allowed: + raid_set=${COMP_WORDS[2]} + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + membership=`echo $membership | sed -e 's/(F)//g'` + echo "$membership" + +run: + raid_set=$3 + member_to_remove=$5 + membership=`cat /proc/mdstat | grep $raid_set | sed -e 's/\[.\]//g' | awk '{ print $5 " " $6 }'` + num_members=`echo $membership | wc -w` + is_in=`echo $membership | grep $member_to_remove` + + if [ -z "$membership" ]; then + echo "$raid_set is not a RAID set" + elif [ -z "$is_in" ]; then + echo "$member_to_remove is not a member of RAID set $raid_set" + echo "actual members are: $membership" + elif [ "$num_members" -eq "1" ]; then + echo "Can't remove last member of a RAID set" + else + echo "removing member $member from RAID set $raid_set" + mdadm /dev/$raid_set --fail /dev/$member_to_remove + if [ $? -ne 0 ]; then + echo "Unable to mark member as failed" + else + sleep 1 + mdadm /dev/$raid_set --remove /dev/$member_to_remove + if [ $? -ne 0 ]; then + echo "Unable to remove member from RAID set" + fi + fi + fi diff --git a/templates/remove/raid/node.tag/node.def b/templates/remove/raid/node.tag/node.def new file mode 100644 index 0000000..a8d8485 --- /dev/null +++ b/templates/remove/raid/node.tag/node.def @@ -0,0 +1,6 @@ +help: Name of RAID set to remove object from + +allowed: + local -a array ; + array=`cat /proc/partitions | grep md | awk '{ print $4 }'` + echo -n $array diff --git a/templates/renew/dhcp/interface/node.tag/node.def b/templates/renew/dhcp/interface/node.tag/node.def index 9952a49..9e6c037 100644 --- a/templates/renew/dhcp/interface/node.tag/node.def +++ b/templates/renew/dhcp/interface/node.tag/node.def @@ -1,7 +1,7 @@ help: Renew DHCP IP address lease for specified interface allowed: local -a array ; - array=( /var/lib/dhcp3/eth* ) ; + array=( /var/lib/dhcp3/eth* /var/lib/dhcp3/br* ) ; echo -n ${array[@]##*/} run: diff --git a/templates/show/disk/node.def b/templates/show/disk/node.def new file mode 100644 index 0000000..8572a9f --- /dev/null +++ b/templates/show/disk/node.def @@ -0,0 +1 @@ +help: Show status of disk device diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def new file mode 100644 index 0000000..e05b4ad --- /dev/null +++ b/templates/show/disk/node.tag/format/node.def @@ -0,0 +1,12 @@ +help: Show disk drive formatting + +run: + disk_dev=$3 + valid_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` + is_a_disk=`echo $valid_disks | grep $disk_dev` + + if [ -z "$is_a_disk" ]; then + echo "$disk_dev is not a disk device" + else + fdisk -l /dev/${disk_dev} + fi diff --git a/templates/show/disk/node.tag/node.def b/templates/show/disk/node.tag/node.def new file mode 100644 index 0000000..7e4fe05 --- /dev/null +++ b/templates/show/disk/node.tag/node.def @@ -0,0 +1,7 @@ +help: Disk device name + +allowed: + local -a array ; + array=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` + echo -n $array + diff --git a/templates/show/dns/dynamic/node.def b/templates/show/dns/dynamic/node.def new file mode 100644 index 0000000..9a06b38 --- /dev/null +++ b/templates/show/dns/dynamic/node.def @@ -0,0 +1 @@ +help: Show Dynamic DNS information diff --git a/templates/show/dns/dynamic/status/node.def b/templates/show/dns/dynamic/status/node.def new file mode 100644 index 0000000..870c883 --- /dev/null +++ b/templates/show/dns/dynamic/status/node.def @@ -0,0 +1,3 @@ +help: Show Dynamic DNS status +run: + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dynamic-dns.pl --show-status diff --git a/templates/show/dns/forwarding/nameservers/node.def b/templates/show/dns/forwarding/nameservers/node.def new file mode 100644 index 0000000..0609f6a --- /dev/null +++ b/templates/show/dns/forwarding/nameservers/node.def @@ -0,0 +1,2 @@ +help: Show DNS forwarding nameservers information +run: sudo /opt/vyatta/bin/sudo-users/vyatta-op-dns-forwarding.pl --show-nameservers diff --git a/templates/show/dns/forwarding/node.def b/templates/show/dns/forwarding/node.def new file mode 100644 index 0000000..eb9ce4b --- /dev/null +++ b/templates/show/dns/forwarding/node.def @@ -0,0 +1 @@ +help: Show DNS forwarding information diff --git a/templates/show/dns/forwarding/statistics/node.def b/templates/show/dns/forwarding/statistics/node.def new file mode 100644 index 0000000..a73b49d --- /dev/null +++ b/templates/show/dns/forwarding/statistics/node.def @@ -0,0 +1,8 @@ +help: Show DNS forwarding statistics +run: + if ps ax | grep dnsmasq | grep -v grep > /dev/null + then + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dns-forwarding.pl --show-statistics + else + echo "DNS forwarding not configured" + fi diff --git a/templates/show/dns/node.def b/templates/show/dns/node.def new file mode 100644 index 0000000..45d0e4f --- /dev/null +++ b/templates/show/dns/node.def @@ -0,0 +1 @@ +help: Show Domain Name Server (DNS) information diff --git a/templates/show/raid/node.def b/templates/show/raid/node.def new file mode 100644 index 0000000..d0ec96d --- /dev/null +++ b/templates/show/raid/node.def @@ -0,0 +1,2 @@ +help: Show status of RAID set + diff --git a/templates/show/raid/node.tag/node.def b/templates/show/raid/node.tag/node.def new file mode 100644 index 0000000..bc83a73 --- /dev/null +++ b/templates/show/raid/node.tag/node.def @@ -0,0 +1,16 @@ +help: RAID set name + +allowed: + local -a raid_sets ; + raid_sets=`cat /proc/partitions | grep md | awk '{ print $4 }'` + echo -n $raid_sets + +run: + raid_set_name=$3 + raid_sets=`cat /proc/partitions | grep md | awk '{ print $4 }'` + valid_set=`echo $raid_sets | grep $raid_set_name` + if [ -z $valid_set ]; then + echo "$raid_set_name is not a RAID set" + else + mdadm --detail /dev/${raid_set_name} + fi
\ No newline at end of file diff --git a/templates/update/dns/dynamic/interface/node.def b/templates/update/dns/dynamic/interface/node.def new file mode 100644 index 0000000..c0ef660 --- /dev/null +++ b/templates/update/dns/dynamic/interface/node.def @@ -0,0 +1 @@ +help: Update Dynamic DNS for specified interface diff --git a/templates/update/dns/dynamic/interface/node.tag/node.def b/templates/update/dns/dynamic/interface/node.tag/node.def new file mode 100644 index 0000000..60fb67d --- /dev/null +++ b/templates/update/dns/dynamic/interface/node.tag/node.def @@ -0,0 +1,6 @@ +help: Update Dynamic DNS for specified interface +allowed: + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dynamic-dns.pl --show-interfaces +run: + IFNAME=${5} + sudo /opt/vyatta/bin/sudo-users/vyatta-op-dynamic-dns.pl --update-ddns --interface "$IFNAME" diff --git a/templates/update/dns/dynamic/node.def b/templates/update/dns/dynamic/node.def new file mode 100644 index 0000000..447fcb5 --- /dev/null +++ b/templates/update/dns/dynamic/node.def @@ -0,0 +1 @@ +help: Update Dynamic DNS information diff --git a/templates/update/dns/node.def b/templates/update/dns/node.def new file mode 100644 index 0000000..b8217f6 --- /dev/null +++ b/templates/update/dns/node.def @@ -0,0 +1 @@ +help: Update DNS information |