]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
6 | * Copyright (C) 1987 by the Massachusetts Institute of Technology | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.1 1987-08-22 17:03:18 wesommer | |
10 | * Initial revision | |
11 | * | |
12 | */ | |
13 | ||
14 | #ifndef lint | |
15 | static char *rcsid_copy_backups_c = "$Header$"; | |
16 | #endif lint | |
17 | #include <stdio.h> | |
18 | #include <strings.h> | |
19 | #include <sys/types.h> | |
20 | #include "update.h" | |
21 | ||
22 | char *whoami; | |
23 | char host[BUFSIZ]; | |
24 | char buf[BUFSIZ]; | |
25 | ||
26 | static struct update_desc info = { | |
27 | 42, /* last_time_tried */ | |
28 | 1, /* success */ | |
29 | 12, /* interval */ | |
30 | "backup", /* service_name */ | |
31 | "ZEUS.MIT.EDU", /* host_name */ | |
32 | "/tmp/frobnicate", /* target_path */ | |
33 | 2, /* override */ | |
34 | 1, /* enable */ | |
35 | "/dev/null" | |
36 | /* instructions */ | |
37 | }; | |
38 | ||
39 | extern char *error_message(); | |
40 | #include <sys/dir.h> | |
41 | ||
42 | main(argc,argv) | |
43 | int argc; | |
44 | char **argv; | |
45 | { | |
46 | int rc; | |
47 | DIR *pd, *sd; | |
48 | struct direct *pde, *sde; | |
49 | ||
50 | whoami = rindex(argv[0], '/'); | |
51 | if (whoami) | |
52 | whoami++; | |
53 | else | |
54 | whoami = argv[0]; | |
55 | whoami = argv[0]; | |
56 | if (chdir ("/u3/sms_backup") < 0) { | |
57 | perror("can't change to /u3/sms_backup"); | |
58 | exit(1); | |
59 | } | |
60 | ||
61 | pd = opendir("."); | |
62 | if (pd == NULL) { | |
63 | perror("can't open sms_backup directory"); | |
64 | exit(1); | |
65 | } | |
66 | ||
67 | while ( (pde = readdir(pd)) != NULL ) { | |
68 | char *dir_name = pde->d_name; | |
69 | printf("Directory: %s\n", dir_name); | |
70 | ||
71 | if (dir_name[0] == '.') continue; /* ignore hidden files */ | |
72 | ||
73 | if (chdir(dir_name) < 0) { | |
74 | perror(dir_name); | |
75 | continue; | |
76 | } | |
77 | sd = opendir ("."); | |
78 | if (sd == NULL) { | |
79 | perror("Can't open ."); | |
80 | goto dotdot; | |
81 | } | |
82 | while ( (sde = readdir(sd)) != NULL ) { | |
83 | if (sde->d_name[0] == '.') continue; | |
84 | ||
85 | sprintf(buf, "/site/sms/sms_backup/%s/%s", dir_name, sde->d_name); | |
86 | printf("Updating: %s\n", buf); | |
87 | info.target_path = buf; | |
88 | rc = sms_update_server(&info, sde->d_name); | |
89 | if (rc) printf("return code: %s\n", error_message(rc)); | |
90 | } | |
91 | closedir(sd); | |
92 | ||
93 | dotdot: | |
94 | chdir(".."); | |
95 | } | |
96 | closedir(pd); | |
97 | } | |
98 | ||
99 | /* | |
100 | * Local Variables: | |
101 | * mode: c | |
102 | * c-indent-level: 4 | |
103 | * c-continued-statement-offset: 4 | |
104 | * c-brace-offset: -4 | |
105 | * c-argdecl-indent: 4 | |
106 | * c-label-offset: -4 | |
107 | * End: | |
108 | */ |