summaryrefslogtreecommitdiffstats
path: root/rescue/install_bootloader
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-10-20 16:52:22 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-10-20 16:52:22 +0000
commite8a7072ea3119f1b93527d9bdca720e80b699350 (patch)
treef49c6859dadb75d1f79cd1be2ee946fdd32a76fc /rescue/install_bootloader
parent21bd24a5b667942d83eb892c932f97c98c525478 (diff)
downloaddrakx-e8a7072ea3119f1b93527d9bdca720e80b699350.tar
drakx-e8a7072ea3119f1b93527d9bdca720e80b699350.tar.gz
drakx-e8a7072ea3119f1b93527d9bdca720e80b699350.tar.bz2
drakx-e8a7072ea3119f1b93527d9bdca720e80b699350.tar.xz
drakx-e8a7072ea3119f1b93527d9bdca720e80b699350.zip
doesn't display prompt if auto
Diffstat (limited to 'rescue/install_bootloader')
-rwxr-xr-xrescue/install_bootloader4
1 files changed, 2 insertions, 2 deletions
diff --git a/rescue/install_bootloader b/rescue/install_bootloader
index ba43eff84..24ab7e382 100755
--- a/rescue/install_bootloader
+++ b/rescue/install_bootloader
@@ -60,9 +60,9 @@ if (@main_methods == 0) {
my $install = $bootloader::{'install_raw_' . $main_method} or die "unknown bootloader method install_raw_$main_method\n";
print "About to re-install Boot Loader $main_method of following Mandriva Linux distribution:\n\t",
- $release,
- "\n=> ok? <press Enter to continue, 'n' and Enter to cancel> ";
+ $release, "\n";
if (!$auto) {
+ print "=> ok? <press Enter to continue, 'n' and Enter to cancel> ";
<STDIN> =~ /^n/i and exit 0;
}
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include <errno.h> #include <stdio.h> #include <stdarg.h> #include <time.h> #include <unistd.h> #include <string.h> #include "module.h" #include "obj.h" #include "modstat.h" #include "util.h" static char snap_dir[] = "/var/log/ksymoops"; /* If snap_dir exists, take a snap shot of ksyms and modules to snap_dir. * Prefix the files with the equivalent of * date +%Y%m%d%T%M%S | sed -e 's/://g' */ void snap_shot(const char *module_names, int n_module_names) { char file[] = "ccyymmddhhmmss.modules", buffer[4096]; static char *infile[] = { "/proc/ksyms", "/proc/modules" }; static char *suffix[] = { "ksyms", "modules" }; struct tm *local; time_t t; int i, l; FILE *in, *out; if (module_names) { /* Only snap shot if the list of modules has changed. * Otherwise auto cleanup takes a snap shot every time * and ends up with a large snap shot directory. */ char *new_module_names; size_t n_new_module_names; get_kernel_info(0); new_module_names = module_name_list; n_new_module_names = n_module_stat; if (n_module_names && n_new_module_names == n_module_names) { while (n_module_names) { if (strcmp(module_names, new_module_names)) break; /* difference detected */ i = strlen(module_names) + 1; module_names += i; new_module_names += i; --n_module_names; } } if (!n_module_names) return; /* no difference, no need for snap shot */ } if (chdir(snap_dir)) return; t = time(NULL); local = localtime(&t); for (i = 0; i < sizeof(infile)/sizeof(infile[0]); ++i) { snprintf(file, sizeof(file), "%04d%02d%02d%02d%02d%02d.%s", local->tm_year+1900, local->tm_mon + 1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec, suffix[i]); out = fopen(file, "w"); if (!out) { error("cannot create %s/%s %m", snap_dir, file); return; } in = fopen(infile[i], "r"); if (!in) { error("cannot open %s %m", infile[i]); return; } while ((l = fread(buffer, 1, sizeof(buffer), in)) > 0) { if (fwrite(buffer, l, 1, out) != 1) { error("unable to write to %s %m", file); fclose(in); fclose(out); return; } } if (ferror(in)) error("unable to read from %s %m", infile[i]); fclose(in); fflush(out); fclose(out); } } /* If snap_dir exists, log a message to snap_dir. The log file is called the * equivalent of date +%Y%m%d | sed -e 's/://g'. Each line is prefixed with * timestamp down to seconds and followed by a newline. */ void snap_shot_log(const char *fmt,...) { char date[] = "ccyymmdd", file[] = "ccyymmdd.log", stamp[] = "ccyymmdd hhmmss"; struct tm *local; time_t t; FILE *log; va_list args; int save_errno = errno; if (chdir(snap_dir)) return; t = time(NULL); local = localtime(&t); snprintf(date, sizeof(date), "%04d%02d%02d", local->tm_year+1900, local->tm_mon + 1, local->tm_mday); snprintf(file, sizeof(file), "%s.log", date); log = fopen(file, "a"); if (!log) { error("cannot create %s/%s %m", snap_dir, file); return; } snprintf(stamp, sizeof(stamp), "%s %02d%02d%02d", date, local->tm_hour, local->tm_min, local->tm_sec); fprintf(log, "%s ", stamp); va_start(args, fmt); errno = save_errno; /* fmt may use %m */ vfprintf(log, fmt, args); va_end(args); fprintf(log, "\n"); fflush(log); fclose(log); }