#!/bin/bash # Author: An-Cheng Huang # Date: 2007 # Description: config notify script # **** License **** # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # This code was originally developed by Vyatta, Inc. # Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc. # All Rights Reserved. # **** End License **** [ -r /etc/default/vyatta ] && source /etc/default/vyatta declare cur_tty=$(ps -o tty= |head -n1) declare cur_user=$(id -un) declare -a ulist=( $(ps -a -o args,tty,ruser n \ | grep "^newgrp $VYATTA_CFG_GROUP_NAME" | cut -c 29-) ) for (( i = 0; i < ${#ulist[@]}; i += 2 )); do utty=${ulist[i]} if [ "$utty" == "$cur_tty" ]; then continue fi user=$(grep "[^:]\+:[^:]*:${ulist[i+1]}:" /etc/passwd | cut -d ':' -f 1) sudo write $user $utty <