home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / bugs / 2bsd / 114 < prev    next >
Encoding:
Text File  |  1993-01-25  |  11.6 KB  |  406 lines

  1. Newsgroups: comp.bugs.2bsd
  2. Path: sparky!uunet!europa.asd.contel.com!wlbr!sms
  3. From: sms@WLV.IIPO.GTEGSC.COM (Steven M. Schultz)
  4. Subject: 'welcome' (a login time information program) (#102)
  5. Message-ID: <1993Jan25.183321.19484@wlbr.iipo.gtegsc.com>
  6. Sender: news@wlbr.iipo.gtegsc.com (news)
  7. Nntp-Posting-Host: wlv.iipo.gtegsc.com
  8. Organization: GTE Government Systems
  9. Date: Mon, 25 Jan 93 18:33:21 GMT
  10. Lines: 394
  11.  
  12. Subject: 'welcome' (a login time information program) (#102)
  13. Index:    local/welcome 2.11BSD
  14.  
  15. Description:
  16.     This is a program contributed by Paul Taylor (taylor@oswego.oswego.edu)
  17.     which gives information about the system in a semi-graphical form
  18.     on VT100 compatible terminals.
  19.  
  20. Repeat-By:
  21.     N/A
  22.  
  23. Fix:
  24.     Cut where indicated, unpack the shar file, cd /usr/src/local/welcome,
  25.     type "make all; make install".
  26.  
  27. ==================================cut here=====================================
  28. #! /bin/sh
  29. # This is a shell archive, meaning:
  30. # 1. Remove everything above the #! /bin/sh line.
  31. # 2. Save the resulting text in a file.
  32. # 3. Execute the file with /bin/sh (not csh) to create:
  33. #    /usr/src/local/welcome
  34. # This archive created: Mon Jan 25 09:27:05 1993
  35. export PATH; PATH=/bin:/usr/bin:$PATH
  36. if test ! -d '/usr/src/local/welcome'
  37. then
  38.     mkdir '/usr/src/local/welcome'
  39. fi
  40. cd '/usr/src/local/welcome'
  41. if test -f 'Makefile'
  42. then
  43.     echo shar: "will not over-write existing file 'Makefile'"
  44. else
  45. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  46. X#    
  47. X#    Makefile for welcome
  48. X#
  49. XDESTDIR=
  50. XBINDIR=    /usr/local
  51. XCFLAGS= -O -DPDP
  52. XSEPFLAG= -i
  53. XPROGRAM=    welcome
  54. XSRCS=        welcome.c
  55. XLIBS=
  56. X
  57. X${PROGRAM}:    ${SRCS}
  58. X    ${CC} ${SEPFLAG} ${CFLAGS} -o $@ $@.c ${LIBS}
  59. X
  60. Xinstall: ${PROGRAM} welcome.0
  61. X    install ${PROGRAM} ${DESTDIR}/${BINDIR}
  62. X    install -c -m 444 -o bin -g bin welcome.0 ${DESTDIR}/usr/local/man/cat1
  63. X
  64. Xwelcome.0: welcome.1
  65. X    /usr/man/manroff welcome.1 > welcome.0
  66. X
  67. Xtags:
  68. X    ctags -tdw *.c
  69. X
  70. Xclean:
  71. X    rm -f a.out core *.o welcome.0 ${PROGRAM}
  72. X
  73. Xdepend:
  74. X    echo 'Welcome Compiled.'
  75. SHAR_EOF
  76. fi
  77. if test -f 'README'
  78. then
  79.     echo shar: "will not over-write existing file 'README'"
  80. else
  81. sed 's/^X//' << \SHAR_EOF > 'README'
  82. XDisclaimer: I originally found this program for VAX/VMS systems in
  83. Xthe March 1988 issue of Hardcopy magazine (page 83).  I do not credit
  84. Xthe idea to me, but since the actual program was in VMS command form,
  85. XI deided it would be nice to put it on an Ultrix compatible system.
  86. XThis program is intended to be shareware.
  87. X
  88. XWelcome prints out a nice welcome message for the user.
  89. X
  90. XVersion 1: Initial program translated, debugged.  At this time there is only
  91. Xa set message in the middle box.  Future copies should work so that it will
  92. Xnlist the kernel and find the type of VAX and version of Ultrix.
  93. X
  94. XVersion 2: Added load average box and LOAD define in cpu.h
  95. X
  96. XVersion 3: Added CPU type and CPU define, along with Ultrix version and
  97. Xhostname.
  98. X
  99. X** This program translated from VMS command language by Jim King at lsrhs
  100. X** (And added a few extra features...)
  101. X
  102. XNOTES --
  103. X
  104. XDefine LOAD if you want the little load average box
  105. X
  106. XDefine CPU If you want to know the type of CPU you are using.
  107. X
  108. XDefine LIGHT if you want the messages in the box highlighted.
  109. X
  110. XDefine UVERS If you want to know the version of Ultrix.
  111. X    NOTE: This program assumes that /etc/motd is a known file
  112. X          produced by /etc/rc.
  113. SHAR_EOF
  114. fi
  115. if test -f 'cpu.h'
  116. then
  117.     echo shar: "will not over-write existing file 'cpu.h'"
  118. else
  119. sed 's/^X//' << \SHAR_EOF > 'cpu.h'
  120. Xint    i;
  121. Xchar    doo[100];
  122. Xchar    poo[100];
  123. XFILE    *fp;
  124. X
  125. X#define    VAX_780        1
  126. X#define    VAX_750        2
  127. X#define    VAX_730        3
  128. X#define VAX_8600    4
  129. X#define VAX_8200    5
  130. X#define VAX_8800    6
  131. X#define MVAX_I        7
  132. X#define MVAX_II        8
  133. X
  134. X/* System defines to be changed-- */
  135. X
  136. X#define    LOAD    /* If you want the load average box, keep this defined. */
  137. X/* #define CPU    /* If you want to know what type CPU you are using, keep
  138. X           this defined.  NOTE: This option has only been tested for
  139. X           Ultrix V2.0, nothing else.  Please... Try it and mail
  140. X           me back! */
  141. X/* #define UVERS    /* If you want to know the version of Ultrix, keep this
  142. X           defined. This will work for any system with /etc/motd.
  143. X#define LIGHT    /* If you want the stuff inside the welcome box inversed,
  144. X           keep this defined. To make it dark, just comment it out. */
  145. X#define TTY    /* If you want the tty box, keep this define        */
  146. SHAR_EOF
  147. fi
  148. if test -f 'welcome.1'
  149. then
  150.     echo shar: "will not over-write existing file 'welcome.1'"
  151. else
  152. sed 's/^X//' << \SHAR_EOF > 'welcome.1'
  153. X.TH welcome 1
  154. X.SH NAME
  155. Xwelcome \- prints out a nice welcome message with useful statistics
  156. X.SH SYNTAX
  157. X.B welcome
  158. X.SH DESCRIPTION
  159. XThe
  160. X.PN welcome
  161. Xcommand makes a graphic box over box and prints out the time, 
  162. Xday, 
  163. Xand system stats
  164. X.PP
  165. X.PN welcome
  166. Xassumes that the file /etc/motd exists.
  167. X.SH SEE ALSO
  168. X/etc/motd
  169. X.SH AUTHOR
  170. XJim King (pulsar) Lincoln-Sudbury Regional High '88.
  171. SHAR_EOF
  172. fi
  173. if test -f 'welcome.c'
  174. then
  175.     echo shar: "will not over-write existing file 'welcome.c'"
  176. else
  177. sed 's/^X//' << \SHAR_EOF > 'welcome.c'
  178. X#include <time.h>
  179. X#include <stdio.h>
  180. X#include "cpu.h"
  181. X#include <nlist.h>
  182. X
  183. X#ifdef PDP
  184. X#include <short_names.h>
  185. X#endif
  186. X
  187. Xextern    struct nlist    namelist[];
  188. Xextern    struct nlist    nl[];
  189. X
  190. Xstruct nlist    nl[] = { { "_cpu" }, { "" } };
  191. Xdouble ldvec[4];
  192. Xint kmem;
  193. X
  194. Xstruct nlist    namelist[] = {
  195. X    { "_avenrun" },
  196. X    { 0 }
  197. X};
  198. X
  199. Xchar *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday",
  200. X         "Thursday", "Friday", "Saturday" };
  201. X
  202. Xchar *mons[] = { "January", "February", "March", "April",
  203. X         "May", "June", "July", "August",
  204. X         "September", "October", "November", "December" };
  205. X
  206. Xchar *ttime[] = { "morning ", "afternoon ", "evening ", "night " };
  207. X
  208. Xmain()
  209. X{
  210. X    register struct tm *det;
  211. X    int a, b, x, y, num, cpu;
  212. X    long secs;
  213. X    char    bot[100], *foo, goo[50], ap;
  214. X    time(&secs);
  215. X#ifdef    LOAD
  216. X#if    defined(PDP)
  217. X    loadav(ldvec);
  218. X#else    defined(PDP)
  219. X    nlist("/vmunix", namelist);
  220. X    if (namelist[0].n_type == 1)
  221. X        puts("/vmunix no namelist\n"), exit(1);
  222. X    kmem = open("/dev/kmem", 0);
  223. X    if (kmem <= 0)
  224. X        printf("cannot open /dev/kmem\n"), exit(1);
  225. X    lseek(kmem, (long)namelist[0].n_value, 0);
  226. X    read(kmem, &ldvec[0], sizeof ldvec);
  227. X    close(kmem);
  228. X#endif    defined(PDP)
  229. X#endif    LOAD
  230. X#ifdef CPU
  231. X    nlist("/vmunix", nl);
  232. X    if (nl[0].n_type == 1)
  233. X        puts("/vmunix no namelist\n"), exit(1);
  234. X    kmem = open("/dev/kmem", 0);
  235. X    if (kmem <= 0)
  236. X        printf("cannot open /dev/kmem\n"), exit(1);
  237. X    lseek(kmem, nl[0].n_value, 0);
  238. X    read(kmem, &cpu, sizeof(cpu));
  239. X    close(kmem);
  240. X#endif CPU
  241. X    ap = "AP"[(det = localtime(&secs))->tm_hour >= 12];
  242. X    if (det->tm_hour > 0 && det->tm_hour < 12)
  243. X        foo = ttime[0];
  244. X    else if (det->tm_hour > 11 && det->tm_hour < 18)
  245. X        foo = ttime[1];
  246. X    else if (det->tm_hour > 17 && det->tm_hour < 24)
  247. X        foo = ttime[2];
  248. X    if ((det->tm_hour %= 12) == 0)
  249. X        det->tm_hour = 12;
  250. X    fflush(stdout);
  251. X    printf("\033[2J\033(0\033)0\033[m");
  252. X#ifdef    LOAD
  253. X    printf("\033[3;11H\033(B\033)B   Load Average\033(0\033)0");
  254. X    printf("\033[4;11Hlqqqqqqqqqqqqqqqqk");
  255. X    printf("\033[5;11Hx                x");
  256. X    printf("\033[6;11Hmqqqqqqqqqqqqqqwqj");
  257. X    printf("\033[5;13H%.02f %.02f %.02f", ldvec[0], ldvec[1], ldvec[2]);
  258. X    printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
  259. X#else   LOAD
  260. X    printf("\033[7;16Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
  261. X#endif    LOAD
  262. X#ifdef    TTY
  263. X    printf("\033[3;51H\033(B\033)BTTY Name\033(0\033)0");
  264. X    printf("\033[4;46Hlqqqqqqqqqqqqqqqqk");
  265. X    printf("\033[5;46Hx                x");
  266. X    printf("\033[6;46Hmqwqqqqqqqqqqqqqqj");
  267. X    printf("\033[5;50H\033(B\033)B%s\033(0\033)0",ttyname(isatty(ttyslot())));
  268. X    printf("\033[7;16Hlqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqk");
  269. X#else   TTY
  270. X    printf("\033[7;16Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk");
  271. X#endif    TTY
  272. X    printf("\033[8;16Hx                                        x");
  273. X    printf("\033[9;13Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
  274. X    printf("\033[10;10Hlqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqk");
  275. X    printf("\033[11;10Hx\033[11;63Hx\033[12;10Hx\033[12;63Hx\033[13;10Hx\033[13;63Hx");
  276. X    printf("\033[14;10Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
  277. X    printf("\033[15;13Hmqqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqj");
  278. X    printf("\033[16;16Hx                                        x");
  279. X    printf("\033[17;16Hmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj");
  280. X    printf("\033(B\033)B");
  281. X#ifdef  LIGHT
  282. X    printf("\033[11;13H\033[7m                                                ");
  283. X#endif  LIGHT
  284. X    printf("\033[11;13H    Good %s%s,", foo, getenv("USER"));
  285. X    gethostname(goo, sizeof(goo));
  286. X#ifdef  LIGHT
  287. X    printf("\033[12;13H\033[7m                                                ");
  288. X    printf("\033[12;13H\033[7m        You have connected to %s", goo);
  289. X#else   LIGHT
  290. X    printf("\033[12;13H        You have connected to %s", goo);
  291. X#endif
  292. X#ifdef  LIGHT
  293. X    printf("\033[13;13H\033[7m                                                ");
  294. X#endif  LIGHT
  295. X#ifdef  CPU
  296. X    printf("\033[m");
  297. X    switch(cpu) {
  298. X        case VAX_780:
  299. X#ifdef LIGHT
  300. X            printf("\033[13;13H\033[7m        A VAX 11/780 running Ultrix");
  301. X#else LIGHT
  302. X            printf("\033[13;13H        A VAX 11/780 running Ultrix");
  303. X#endif LIGHT
  304. X            break;
  305. X        case VAX_750:
  306. X#ifdef LIGHT
  307. X            printf("\033[13;13H\033[7m        A VAX 11/750 running Ultrix");
  308. X#else LIGHT
  309. X            printf("\033[13;13H        A VAX 11/750 running Ultrix");
  310. X#endif LIGHT
  311. X            break;
  312. X        case VAX_730:
  313. X#ifdef LIGHT
  314. X            printf("\033[13;13H\033[7m        A VAX 11/730 running Ultrix");
  315. X#else LIGHT
  316. X            printf("\033[13;13H        A VAX 11/730 running Ultrix");
  317. X#endif LIGHT
  318. X            break;
  319. X        case VAX_8600:
  320. X#ifdef LIGHT
  321. X            printf("\033[13;13H\033[7m        A VAX 8600 running Ultrix");
  322. X#else LIGHT
  323. X            printf("\033[13;13H        A VAX 8600 running Ultrix");
  324. X#endif LIGHT
  325. X            break;
  326. X        case VAX_8200:
  327. X#ifdef LIGHT
  328. X            printf("\033[13;13H\033[7m        A VAX 8200 running Ultrix");
  329. X#else LIGHT
  330. X            printf("\033[13;13H        A VAX 8200 running Ultrix");
  331. X#endif LIGHT
  332. X            break;
  333. X        case VAX_8800:
  334. X#ifdef LIGHT
  335. X            printf("\033[13;13H\033[7m        A VAX 8800 running Ultrix");
  336. X#else LIGHT
  337. X            printf("\033[13;13H        A VAX 8800 running Ultrix");
  338. X#endif LIGHT
  339. X            break;
  340. X        case MVAX_I:
  341. X#ifdef LIGHT
  342. X            printf("\033[13;13H\033[7m        A MicroVAX I running Ultrix");
  343. X#else LIGHT
  344. X            printf("\033[13;13H        A MicroVAX I running Ultrix");
  345. X#endif LIGHT
  346. X            break;
  347. X        case MVAX_II:
  348. X#ifdef LIGHT
  349. X            printf("\033[13;13H\033[7m        A MicroVAX II running Ultrix");
  350. X#else LIGHT
  351. X            printf("\033[13;13H        A MicroVAX II running Ultrix");
  352. X#endif LIGHT
  353. X            break;
  354. X        default:
  355. X            printf("\033[13;13H        CPU ident error");
  356. X            break;
  357. X    }
  358. X#else   CPU
  359. X#ifdef LIGHT
  360. X#if defined(PDP)
  361. X    printf("\033[13;13H\033[7m        A PDP-11 running 2.11BSD");
  362. X#else defined(PDP)
  363. X    printf("\033[13;13H\033[7m        A system running Ultrix");
  364. X#endif defined(PDP)
  365. X#else  LIGHT
  366. X#if defined(PDP)
  367. X    printf("\033[13;13H        A PDP-11 running 2.11BSD");
  368. X#else defined(PDP)
  369. X    printf("\033[13;13H        A system running Ultrix");
  370. X#endif defined(PDP)
  371. X#endif LIGHT
  372. X#endif  CPU
  373. X#ifdef    UVERS
  374. X    fp = fopen("/etc/motd", "r");
  375. X    fscanf(fp, "%s%s", poo, doo);
  376. X    printf(" V%c.%c", doo[1], doo[3]);
  377. X    fclose(fp);
  378. X    unlink("/tmp/foo");
  379. X#endif    UVERS
  380. X#ifdef    LIGHT
  381. X    printf("\033[8;18H                                      ");
  382. X    printf("\033[16;18H                                      ");
  383. X#endif    LIGHT
  384. X    x = 40 - (strlen(days[det->tm_wday]) / 2);
  385. X    y = (69 - x);
  386. X    printf("\033[8;%dH%s", y, days[det->tm_wday]);
  387. X    sprintf(bot, "%s %d, 19%d %d:%02d %cM", mons[det->tm_mon],
  388. X            det->tm_mday, det->tm_year, det->tm_hour,
  389. X        det->tm_min, ap);
  390. X    a = 40 -(strlen(bot) / 2);
  391. X    b = (54 - a);
  392. X    printf("\033[m");
  393. X#ifdef LIGHT
  394. X    printf("\033[7m");
  395. X#endif LIGHT
  396. X    printf("\033[16;%dH%s", b, bot);
  397. X    printf("\033[23;1H");
  398. X    printf("\033[m");
  399. X    exit(0);
  400. X}
  401. SHAR_EOF
  402. fi
  403. cd ..
  404. exit 0
  405. #    End of shell archive
  406.