blob: 3735472a38092981e86718cbc7389bcc67476882 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Dees_Troy51a0e822012-09-05 15:24:24 -040017#include <errno.h>
18#include <fcntl.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040019#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <sys/stat.h>
23#include <sys/types.h>
24#include <sys/wait.h>
25#include <unistd.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040026#include <linux/input.h>
Dees_Troy51a0e822012-09-05 15:24:24 -040027
Dees_Troy51a0e822012-09-05 15:24:24 -040028#include "bootloader.h"
29#include "common.h"
30#include "extra-functions.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040031#include "data.h"
32#include "variables.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040033
34void run_script(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5, const char *str6, const char *str7, int request_confirm)
35{
36 ui_print("%s", str1);
Dees_Troy8170a922012-09-18 15:40:25 -040037 ui_print("%s", str2);
38 pid_t pid = fork();
39 if (pid == 0) {
40 char *args[] = { "/sbin/sh", "-c", (char*)str3, "1>&2", NULL };
41 execv("/sbin/sh", args);
42 fprintf(stderr, str4, strerror(errno));
43 _exit(-1);
44 }
45 int status;
46 while (waitpid(pid, &status, WNOHANG) == 0) {
47 ui_print(".");
48 sleep(1);
49 }
50 ui_print("\n");
51 if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
52 ui_print("%s", str5);
53 } else {
54 ui_print("%s", str6);
55 }
Dees_Troy51a0e822012-09-05 15:24:24 -040056}
57