<commit_before>#!/bin/bash
. /opt/farm/scripts/init
. /opt/farm/scripts/functions.custom

PV=0
VM=0
VZ=0
LXC=0
DCK=0
WKS=0
DEF=1
command=$@

if [ "$1" = "" ]; then
	echo "usage: $0 [-pv] [-vm] [-vz] [-lxc] [-dck] [-wks] command argument(s)"
	exit 1
fi

while [ "$1" = "-pv" ] || [ "$1" = "-vm" ] || [ "$1" = "-vz" ] || [ "$1" = "-lxc" ] || [ "$1" = "-dck" ] || [ "$1" = "-wks" ]; do
	DEF=0
	if   [ "$1" = "-pv" ]; then PV=1
	elif [ "$1" = "-vm" ]; then VM=1
	elif [ "$1" = "-vz" ]; then VZ=1
	elif [ "$1" = "-lxc" ]; then LXC=1
	elif [ "$1" = "-dck" ]; then DCK=1
	elif [ "$1" = "-wks" ]; then WKS=1
	fi
	shift
	command=$@
done

# default behaviour, when no -xx switches are used: execute command only on virtual machines
if [ $DEF = 1 ]; then
	VM=1
fi


connect_loop() {
	for server in `cat /etc/local/.config/$2`; do
		sshkey="`ssh_management_key_storage_filename $server`"
		echo
		echo "####### executing \"$1\" on $3 $server"
		ssh -t -i $sshkey -o StrictHostKeyChecking=no root@$server "$1"
	done
}

if [ $WKS = 1 ]; then connect_loop "$command" workstation.hosts "workstation"; fi
if [ $PV = 1 ]; then connect_loop "$command" physical.hosts "physical server"; fi
if [ $VM = 1 ]; then connect_loop "$command" virtual.hosts "virtual server"; fi

if [ $VZ = 1 ]; then
    for server in `cat /etc/local/.config/openvz.hosts`; do
        sshkey="`ssh_management_key_storage_filename $server`"
        containers="`ssh -i $sshkey root@$server \"/usr/sbin/vzlist -Ho ctid\"`"

        for ID in $containers; do
            cthost="`ssh -i $sshkey root@$server \"/usr/sbin/vzlist -Ho hostname $ID\"`"
            echo "\n####### executing \"$command\" on container $ID [$cthost] at server $server"
            ssh -t -i $sshkey root@$server "/usr/sbin/vzctl exec $ID \"TERM=vt100 $command\""
        done
    done
fi

if [ $LXC = 1 ]; then echo "skipping LXC containers; not implemented yet"; fi
if [ $DCK = 1 ]; then echo "skipping Docker containers; not implemented yet"; fi<commit_msg>pv switch renamed to ph<commit_after>#!/bin/bash
. /opt/farm/scripts/init
. /opt/farm/scripts/functions.custom

PH=0
VM=0
VZ=0
LXC=0
DCK=0
WKS=0
DEF=1
command=$@

if [ "$1" = "" ]; then
	echo "usage: $0 [-ph] [-vm] [-vz] [-lxc] [-dck] [-wks] command argument(s)"
	exit 1
fi

while [ "$1" = "-ph" ] || [ "$1" = "-vm" ] || [ "$1" = "-vz" ] || [ "$1" = "-lxc" ] || [ "$1" = "-dck" ] || [ "$1" = "-wks" ]; do
	DEF=0
	if   [ "$1" = "-ph" ]; then PH=1
	elif [ "$1" = "-vm" ]; then VM=1
	elif [ "$1" = "-vz" ]; then VZ=1
	elif [ "$1" = "-lxc" ]; then LXC=1
	elif [ "$1" = "-dck" ]; then DCK=1
	elif [ "$1" = "-wks" ]; then WKS=1
	fi
	shift
	command=$@
done

# default behaviour, when no -xx switches are used: execute command only on virtual machines
if [ $DEF = 1 ]; then
	VM=1
fi


connect_loop() {
	for server in `cat /etc/local/.config/$2`; do
		sshkey="`ssh_management_key_storage_filename $server`"
		echo
		echo "####### executing \"$1\" on $3 $server"
		ssh -t -i $sshkey -o StrictHostKeyChecking=no root@$server "$1"
	done
}

if [ $WKS = 1 ]; then connect_loop "$command" workstation.hosts "workstation"; fi
if [ $PH = 1 ]; then connect_loop "$command" physical.hosts "physical server"; fi
if [ $VM = 1 ]; then connect_loop "$command" virtual.hosts "virtual server"; fi

if [ $VZ = 1 ]; then
    for server in `cat /etc/local/.config/openvz.hosts`; do
        sshkey="`ssh_management_key_storage_filename $server`"
        containers="`ssh -i $sshkey root@$server \"/usr/sbin/vzlist -Ho ctid\"`"

        for ID in $containers; do
            cthost="`ssh -i $sshkey root@$server \"/usr/sbin/vzlist -Ho hostname $ID\"`"
            echo
            echo "####### executing \"$command\" on container $ID [$cthost] at server $server"
            ssh -t -i $sshkey root@$server "/usr/sbin/vzctl exec $ID \"TERM=vt100 $command\""
        done
    done
fi

if [ $LXC = 1 ]; then echo "skipping LXC containers; not implemented yet"; fi
if [ $DCK = 1 ]; then echo "skipping Docker containers; not implemented yet"; fi
{'fraction_non_alphanumeric': 0.19929982495623905, 'fraction_numerical': 0.022005501375343836, 'mean_word_length': 3.028197381671702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7334632', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1544, 'n_words': 465}