057254477cf03b078634ce75acd7e740e5e9df5f
[feisty_meow.git] / scripts / users / byejob.sh
1 #!/bin/bash
2
3 # this program is run in the background to show a bye message on the console.
4
5 export LIGHTWEIGHT_INIT=true  # make sure we just get our variables.
6 source $HOME/yeti/scripts/launch_feisty_meow.sh
7 export host=$(hostname)
8
9 source $FEISTY_MEOW_SCRIPTS/core/date_stringer.sh
10
11 # use this to always print the message.
12 #  export hostlist=$host
13
14 # only print on a few...
15 export hostlist='chandra ducky equanimity gulliver hamstergate \
16   mycroft mrowrt numenor shaggy simmy slowboat velma wolfe \
17 \
18   dervish frylock lagomorph shakezula '
19 #hmmm: this hostlist is highly dependent on my own favorite host names.
20 # to commoditize this, we should instead use a config file for the list.
21
22 # set our domain name based on what's found in the resolv.conf file, where
23 # dns info is often found.
24 DOMAIN_NAME=$(grep -i search </etc/resolv.conf | tail -1 | sed -n -e 's/domain.\(.*\)$/\1/p')
25 if [ -z "$DOMAIN_NAME" ]; then
26   # second try, searching out the search domain as a suitable replacement
27   # for the actual domain being specified.
28   DOMAIN_NAME=$(grep -i search </etc/resolv.conf | tail -1 | sed -n -e 's/search.\(.*\)$/\1/p')
29 fi
30 # oh well, we don't know what the heck the domain is.
31 if [ -z "$DOMAIN_NAME" ]; then DOMAIN_NAME=unknown_domain; fi
32
33 echo domain is $DOMAIN_NAME
34
35 for i in $hostlist; do
36   if [ "$host" = "$i" -o "$host" = "$i.$DOMAIN_NAME" ]; then
37 #    echo $(date_stringer)": $host matched." >>$HOME/host_matched_in_byejob.txt
38     ( /bin/bash <<end
39       sleep 7; bash $FEISTY_MEOW_SCRIPTS/users/byemessage.sh /dev/console
40 end
41     )&
42 jobs
43   fi
44 done
45