From b81d4faa0fd65a42ae4a9a0191b4684d3aa7ff62 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Mon, 18 May 2009 15:51:54 +0000 Subject: [PATCH] Getting rid of scripts from the vsys package. These scripts can be found in the vsys-scripts package. --- factory/comon_exec | 40 ------------------- factory/hide_netif | 6 --- factory/nfsmount | 51 ------------------------ factory/pfmount | 10 ----- factory/pl-ps | 36 ----------------- factory/portsummary | 63 ----------------------------- factory/setup-link | 96 --------------------------------------------- factory/setup-nat | 57 --------------------------- factory/vtop | 12 ------ vsys.spec | 2 +- 10 files changed, 1 insertion(+), 372 deletions(-) delete mode 100755 factory/comon_exec delete mode 100755 factory/hide_netif delete mode 100755 factory/nfsmount delete mode 100755 factory/pfmount delete mode 100755 factory/pl-ps delete mode 100755 factory/portsummary delete mode 100755 factory/setup-link delete mode 100755 factory/setup-nat delete mode 100755 factory/vtop diff --git a/factory/comon_exec b/factory/comon_exec deleted file mode 100755 index df6e7c0..0000000 --- a/factory/comon_exec +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl -use strict; - -####################################################### -# -# run any (allowed) progam in the root context -# -####################################################### - -my @allowed = ("/bin/df"); # allowed commands -my $cmdline; -my $path; -my $p; - -# read command line -$cmdline = ; -chomp($cmdline); - -# identify the path -if ($cmdline =~ /\s*(.+)\s+/) { - $path = $1; -} else { - $path = $cmdline; -} - -# run the program if it's executable and allowed to run -if (-x $path) { - foreach $p (@allowed) { - if ($p eq $path) { - system($cmdline); - exit(0); - } - } - print "fatal: '$cmdline' is not allowed to run\n"; -} else { - print "fatal: $path either does not exist or is not executable\n"; -} - -# some error occurred -exit(-1); diff --git a/factory/hide_netif b/factory/hide_netif deleted file mode 100755 index c7ae234..0000000 --- a/factory/hide_netif +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Remove hide_netif network attribute. Attribute is used to hide interfaces that don't have an IP attached. - -# $Id$ - -nattribute --set --nid $1 --flag ~hide_netif diff --git a/factory/nfsmount b/factory/nfsmount deleted file mode 100755 index 04115dc..0000000 --- a/factory/nfsmount +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my $slicename=$ARGV[0]; -my $already_mounted_testfile = "/tmp/$slicename"."_nfsmounted"; - -my $slice_dir="/vservers/$slicename/"; - -if (-f $already_mounted_testfile) { - die("Sorry, only one successful NFS mount allowed per slice!"); -} - -my $remotepath = ; -my $localpath = ; -chomp($localpath); -chomp($remotepath); -$localpath=~s/\.\.//g; - -$localpath=$slice_dir.$localpath; - -unless (-d $localpath) { - die("Localpath does not exist, please create it first."); -} - -my $hostexpr="(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?$already_mounted_testfile"; - print FIL "$remotepath $localpath"; - close FIL; -} diff --git a/factory/pfmount b/factory/pfmount deleted file mode 100755 index 0282c76..0000000 --- a/factory/pfmount +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Mount the planetflow directory in a slice - -#mount --bind /usr/local/fprobe /vservers/$1/pf -# changed from request of Faiyaz -DEST="/vservers/$1/pf" -mount | grep "on $DEST type" > /dev/null -if [ $? -eq 1 ]; then - mount --bind /var/local/fprobe -o ro $DEST -fi diff --git a/factory/pl-ps b/factory/pl-ps deleted file mode 100755 index eafdf5b..0000000 --- a/factory/pl-ps +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl -use strict; - -############################################### -# pl-ps for slicestat by KyoungSoo Park -############################################### - -my %slice_id; -my %slice; - -open THIS_PIPE, "/bin/awk -F: \'{print \$1, \$3}\' /etc/passwd |"; -while() { - if (/(.+)\s+(\d+)/) { - $slice_id{$1} = $2; - $slice{$2} = $1; - } -} -close THIS_PIPE; - -open THIS_PIPE, "/usr/sbin/vps -eo pid,user | sed 1d | awk \'{print \$1, \$2}\' | sort -k 2 |"; -while() { - if (/(\d+)\s+(.+)$/) { - my $pid = $1; - my ($id, $sl); - - if (defined($slice_id{$2})) { - $id = $slice_id{$2}; - $sl = $2; - } else { - $id = $2; - $sl = $slice{$2}; - } - print sprintf("%s %s %s\n", $id, $sl, $pid); - } -} -close THIS_PIPE; diff --git a/factory/portsummary b/factory/portsummary deleted file mode 100755 index f800632..0000000 --- a/factory/portsummary +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python - -import os -import sys - -# NOTE: '--inet' lists only ipv4 addresses. -ns = os.popen("ncontext --nid 1 --migrate -- vcontext --xid 1 --migrate -- netstat -apnlut --inet", 'r') -port_summary = {} -for line in ns: - try: - ns_fields = line.split() - if ns_fields[0] == "tcp" or ns_fields[0] == "udp": - (src_ip, src_port) = ns_fields[3].split(':') - (dst_ip, dst_port) = ns_fields[4].split(':') - - port_key='%s-%s' % (src_port, dst_port) - - if src_ip is not "0.0.0.0" and port_key in port_summary: - # skip INADDR_ANY addresses and ports we've already seen. - continue - - conn_state = ns_fields[5] - if ns_fields[0] == "tcp": - proc_field = ns_fields[6] - else: - if conn_state == "ESTABLISHED": - proc_field = ns_fields[6] - else: - proc_field = ns_fields[5] - - if proc_field != "-": - (pid,procname)= proc_field.split('/') - else: - # NOTE: without a PID there is no way to associate with an XID - continue - - if ( ns_fields[0] == "tcp" and src_ip == "0.0.0.0" and conn_state == "LISTEN" ) or \ - ( ns_fields[0] == "udp" and src_ip == "0.0.0.0" ): - type='C' - elif src_ip == "127.0.0.1": - type='l' - elif src_ip != "0.0.0.0" and src_ip != "127.0.0.1": - type='c' - else: - type='?' - - xid_stream = os.popen("vserver-info %s XID" % pid) - xid = xid_stream.read() - - port_summary[port_key] = {'prot' : ns_fields[0], - 'src_port' : src_port, - 'dst_port' : dst_port, - 'slice' : xid[:-1], - 'type': type} - except: - import traceback; traceback.print_exc() - print line - -ports = port_summary.keys() -ports.sort() -for port in ports: - print "%(prot)4s\t%(src_port)6s\t%(dst_port)6s\t%(slice)5s\t%(type)s" % port_summary[port] - diff --git a/factory/setup-link b/factory/setup-link deleted file mode 100755 index e5cbd2f..0000000 --- a/factory/setup-link +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh +x - -IP=/sbin/ip - -SLICE=$1 -SLICEID=`id -u $SLICE` -read INDEX -read REMOTE -read KEY - -LINK=${KEY}if${INDEX} - -modprobe ip_gre -modprobe etun - -### Setup EGRE tunnel -EGRE=d$LINK -$IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY -$IP link set $EGRE up - -### Setup etun -ETUN0=a$LINK -ETUN1=b$LINK -echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif -ifconfig $ETUN0 mtu 1458 up -ifconfig $ETUN1 up - -### Setup bridge -BRIDGE=c$LINK -brctl addbr $BRIDGE -brctl addif $BRIDGE $EGRE -brctl addif $BRIDGE $ETUN1 -ifconfig $BRIDGE up - -### Setup iptables so that packets are visible in the vserver -iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID - -### Create "grab link" script -GRAB=/vsys/local_grab-$ETUN0 -echo $SLICE > $GRAB.acl -rm -f $GRAB -cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid -EOF -chmod +x $GRAB - -### Create script for setting link rate -BIND=/vsys/local_rate-$ETUN0 -echo $SLICE > $BIND.acl -rm -f $BIND -cat > $BIND < $DELETE.acl -rm -f $DELETE -cat > $DELETE < /sys/module/etun/parameters/delif - -# Get rid of bridge -ifconfig $BRIDGE down -brctl delbr $BRIDGE - -# Get rid of EGRE tunnel -ip tunnel del $EGRE - -# Clean up files -rm -f $GRAB $GRAB.acl -rm -f $DELETE $DELETE.acl -rm -f $BIND $BIND.acl -EOF -chmod +x $DELETE diff --git a/factory/setup-nat b/factory/setup-nat deleted file mode 100755 index 64be40b..0000000 --- a/factory/setup-nat +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh +x - -IP=/sbin/ip - -SLICE=$1 -SLICEID=`id -u $SLICE` -read KEY - -modprobe etun - -### Setup etun -ETUN0=nat$KEY -ETUN1=natx$KEY -echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif -ifconfig $ETUN1 10.0.$KEY.1 up - -/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE -/sbin/iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT -/sbin/iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT - -### Create "grab link" script -GRAB=/vsys/local_grab-$ETUN0 -echo $SLICE > $GRAB.acl -rm -f $GRAB -cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid -EOF -chmod +x $GRAB - -### Create "delete link" script -DELETE=/vsys/local_delete-$ETUN0 -echo $SLICE > $DELETE.acl -rm -f $DELETE -cat > $DELETE < /sys/module/etun/parameters/delif - -# Clean up files -rm -f $GRAB $GRAB.acl -rm -f $DELETE $DELETE.acl - -EOF -chmod +x $DELETE - diff --git a/factory/vtop b/factory/vtop deleted file mode 100755 index 00e44c0..0000000 --- a/factory/vtop +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/perl -use strict; - -############################################### -# vtop for slicestat by KyoungSoo Park -############################################### - -open THIS_PIPE, "/usr/sbin/vtop bn1 |"; -while() { - print; -} -close THIS_PIPE; diff --git a/vsys.spec b/vsys.spec index 29b2311..cc42bf5 100644 --- a/vsys.spec +++ b/vsys.spec @@ -50,7 +50,7 @@ make mkdir -p $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/vsys -cp factory/* $RPM_BUILD_ROOT/vsys +#cp factory/* $RPM_BUILD_ROOT/vsys cp vsys $RPM_BUILD_ROOT/usr/bin cp vsys-initscript $RPM_BUILD_ROOT/etc/init.d/vsys cp vsys.conf $RPM_BUILD_ROOT/etc -- 2.43.0