mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-17 06:23:00 +02:00
libsmooth+install: Fix output redirection
This commit is contained in:
@@ -48,12 +48,12 @@ const char* other_filesystems[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int system_chroot(const char* path, const char* cmd) {
|
||||
static int system_chroot(const char* output, const char* path, const char* cmd) {
|
||||
char chroot_cmd[STRING_SIZE];
|
||||
|
||||
snprintf(chroot_cmd, sizeof(chroot_cmd), "/usr/sbin/chroot %s %s", path, cmd);
|
||||
|
||||
return mysystem(chroot_cmd);
|
||||
return mysystem(output, chroot_cmd);
|
||||
}
|
||||
|
||||
struct hw* hw_init() {
|
||||
@@ -526,7 +526,7 @@ static int hw_zero_out_device(const char* path, int bytes) {
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
int hw_create_partitions(struct hw_destination* dest) {
|
||||
int hw_create_partitions(struct hw_destination* dest, const char* output) {
|
||||
// Before we write a new partition table to the disk, we will erase
|
||||
// the first couple of megabytes at the beginning of the device to
|
||||
// get rid of all left other things like bootloaders and partition tables.
|
||||
@@ -597,7 +597,7 @@ int hw_create_partitions(struct hw_destination* dest) {
|
||||
asprintf(&cmd, "%s disk_set pmbr_boot on", cmd);
|
||||
}
|
||||
|
||||
r = mysystem(cmd);
|
||||
r = mysystem(output, cmd);
|
||||
|
||||
// Wait until the system re-read the partition table
|
||||
if (r == 0) {
|
||||
@@ -632,7 +632,7 @@ int hw_create_partitions(struct hw_destination* dest) {
|
||||
return r;
|
||||
}
|
||||
|
||||
static int hw_format_filesystem(const char* path, int fs) {
|
||||
static int hw_format_filesystem(const char* path, int fs, const char* output) {
|
||||
char cmd[STRING_SIZE] = "\0";
|
||||
|
||||
// Swap
|
||||
@@ -657,36 +657,36 @@ static int hw_format_filesystem(const char* path, int fs) {
|
||||
|
||||
assert(*cmd);
|
||||
|
||||
int r = mysystem(cmd);
|
||||
int r = mysystem(output, cmd);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int hw_create_filesystems(struct hw_destination* dest) {
|
||||
int hw_create_filesystems(struct hw_destination* dest, const char* output) {
|
||||
int r;
|
||||
|
||||
// boot
|
||||
if (*dest->part_boot) {
|
||||
r = hw_format_filesystem(dest->part_boot, dest->filesystem);
|
||||
r = hw_format_filesystem(dest->part_boot, dest->filesystem, output);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
// swap
|
||||
if (*dest->part_swap) {
|
||||
r = hw_format_filesystem(dest->part_swap, HW_FS_SWAP);
|
||||
r = hw_format_filesystem(dest->part_swap, HW_FS_SWAP, output);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
// root
|
||||
r = hw_format_filesystem(dest->part_root, dest->filesystem);
|
||||
r = hw_format_filesystem(dest->part_root, dest->filesystem, output);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
// data
|
||||
if (*dest->part_data) {
|
||||
r = hw_format_filesystem(dest->part_data, dest->filesystem);
|
||||
r = hw_format_filesystem(dest->part_data, dest->filesystem, output);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
@@ -809,26 +809,26 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hw_destroy_raid_superblocks(const struct hw_destination* dest) {
|
||||
static int hw_destroy_raid_superblocks(const struct hw_destination* dest, const char* output) {
|
||||
char cmd[STRING_SIZE];
|
||||
|
||||
hw_stop_all_raid_arrays();
|
||||
hw_stop_all_raid_arrays();
|
||||
hw_stop_all_raid_arrays(output);
|
||||
hw_stop_all_raid_arrays(output);
|
||||
|
||||
if (dest->disk1) {
|
||||
snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk1);
|
||||
mysystem(cmd);
|
||||
snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk1->path);
|
||||
mysystem(output, cmd);
|
||||
}
|
||||
|
||||
if (dest->disk2) {
|
||||
snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk2);
|
||||
mysystem(cmd);
|
||||
snprintf(cmd, sizeof(cmd), "/sbin/mdadm --zero-superblock %s", dest->disk2->path);
|
||||
mysystem(output, cmd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hw_setup_raid(struct hw_destination* dest) {
|
||||
int hw_setup_raid(struct hw_destination* dest, const char* output) {
|
||||
char* cmd = NULL;
|
||||
int r;
|
||||
|
||||
@@ -837,7 +837,7 @@ int hw_setup_raid(struct hw_destination* dest) {
|
||||
// Stop all RAID arrays that might be around (again).
|
||||
// It seems that there is some sort of race-condition with udev re-enabling
|
||||
// the raid arrays and therefore locking the disks.
|
||||
r = hw_destroy_raid_superblocks(dest);
|
||||
r = hw_destroy_raid_superblocks(dest, output);
|
||||
|
||||
asprintf(&cmd, "echo \"y\" | /sbin/mdadm --create --verbose --metadata=%s --auto=mdp %s",
|
||||
RAID_METADATA, dest->path);
|
||||
@@ -869,7 +869,7 @@ int hw_setup_raid(struct hw_destination* dest) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = mysystem(cmd);
|
||||
r = mysystem(output, cmd);
|
||||
free(cmd);
|
||||
|
||||
// Wait a moment until the device has been properly brought up
|
||||
@@ -892,17 +892,17 @@ int hw_setup_raid(struct hw_destination* dest) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int hw_stop_all_raid_arrays() {
|
||||
return mysystem("/sbin/mdadm --stop --scan --verbose");
|
||||
int hw_stop_all_raid_arrays(const char* output) {
|
||||
return mysystem(output, "/sbin/mdadm --stop --scan --verbose");
|
||||
}
|
||||
|
||||
int hw_install_bootloader(struct hw_destination* dest) {
|
||||
int hw_install_bootloader(struct hw_destination* dest, const char* output) {
|
||||
char cmd[STRING_SIZE];
|
||||
int r;
|
||||
|
||||
// Generate configuration file
|
||||
snprintf(cmd, sizeof(cmd), "/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg");
|
||||
r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
|
||||
r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
@@ -911,15 +911,15 @@ int hw_install_bootloader(struct hw_destination* dest) {
|
||||
|
||||
if (dest->is_raid) {
|
||||
snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk1->path);
|
||||
r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
|
||||
r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk2->path);
|
||||
r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
|
||||
r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
|
||||
} else {
|
||||
snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->path);
|
||||
r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
|
||||
r = system_chroot(output, DESTINATION_MOUNT_PATH, cmd);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
@@ -112,16 +112,16 @@ struct hw_destination* hw_make_destination(int part_type, struct hw_disk** disks
|
||||
|
||||
unsigned long long hw_memory();
|
||||
|
||||
int hw_create_partitions(struct hw_destination* dest);
|
||||
int hw_create_filesystems(struct hw_destination* dest);
|
||||
int hw_create_partitions(struct hw_destination* dest, const char* output);
|
||||
int hw_create_filesystems(struct hw_destination* dest, const char* output);
|
||||
|
||||
int hw_mount_filesystems(struct hw_destination* dest, const char* prefix);
|
||||
int hw_umount_filesystems(struct hw_destination* dest, const char* prefix);
|
||||
|
||||
int hw_setup_raid(struct hw_destination* dest);
|
||||
int hw_stop_all_raid_arrays();
|
||||
int hw_setup_raid(struct hw_destination* dest, const char* output);
|
||||
int hw_stop_all_raid_arrays(const char* output);
|
||||
|
||||
int hw_install_bootloader(struct hw_destination* dest);
|
||||
int hw_install_bootloader(struct hw_destination* dest, const char* output);
|
||||
int hw_write_fstab(struct hw_destination* dest);
|
||||
|
||||
void hw_sync();
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
#include <libsmooth.h>
|
||||
|
||||
/* unattended.c */
|
||||
int unattended_setup(struct keyvalue *unattendedkv);
|
||||
int unattended_setup(struct keyvalue *unattendedkv, const char* output);
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
|
||||
#define LICENSE_FILE "/cdrom/COPYING"
|
||||
|
||||
FILE *flog = NULL;
|
||||
char *mylog;
|
||||
|
||||
extern char url[STRING_SIZE];
|
||||
|
||||
static int newtChecklist(const char* title, const char* message,
|
||||
@@ -225,6 +222,7 @@ static struct lang {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct hw* hw = hw_init();
|
||||
const char* logfile = NULL;
|
||||
|
||||
// Read /etc/system-release
|
||||
char* system_release = get_system_release();
|
||||
@@ -251,16 +249,16 @@ int main(int argc, char *argv[]) {
|
||||
sethostname( SNAME , 10);
|
||||
|
||||
/* Log file/terminal stuff. */
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (!(flog = fopen(argv[1], "w+")))
|
||||
FILE* flog = NULL;
|
||||
if (argc >= 2) {
|
||||
logfile = argv[1];
|
||||
|
||||
if (!(flog = fopen(logfile, "w+")))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
mylog = argv[1];
|
||||
|
||||
}
|
||||
|
||||
fprintf(flog, "Install program started.\n");
|
||||
|
||||
newtInit();
|
||||
@@ -287,7 +285,7 @@ int main(int argc, char *argv[]) {
|
||||
// check if we have to make an unattended install
|
||||
if (strstr (line, "unattended") != NULL) {
|
||||
unattended = 1;
|
||||
runcommandwithstatus("/bin/sleep 10", title, "WARNING: Unattended installation will start in 10 seconds...");
|
||||
runcommandwithstatus("/bin/sleep 10", title, "WARNING: Unattended installation will start in 10 seconds...", NULL);
|
||||
}
|
||||
// check if we have to patch for serial console
|
||||
if (strstr (line, "console=ttyS0") != NULL) {
|
||||
@@ -296,8 +294,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// Load common modules
|
||||
mysystem("/sbin/modprobe vfat"); // USB key
|
||||
hw_stop_all_raid_arrays();
|
||||
mysystem(logfile, "/sbin/modprobe vfat"); // USB key
|
||||
hw_stop_all_raid_arrays(logfile);
|
||||
|
||||
if (!unattended) {
|
||||
// Language selection
|
||||
@@ -337,7 +335,7 @@ int main(int argc, char *argv[]) {
|
||||
fprintf(flog, "Source drive: %s\n", sourcedrive);
|
||||
if (!sourcedrive) {
|
||||
newtWinMessage(title, _("OK"), _("No local source media found. Starting download."));
|
||||
runcommandwithstatus("/bin/downloadsource.sh", title, _("Downloading installation image ..."));
|
||||
runcommandwithstatus("/bin/downloadsource.sh", title, _("Downloading installation image ..."), logfile);
|
||||
if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
|
||||
errorbox(_("Download error"));
|
||||
goto EXIT;
|
||||
@@ -533,7 +531,7 @@ int main(int argc, char *argv[]) {
|
||||
if (destination->is_raid) {
|
||||
statuswindow(60, 4, title, _("Building RAID..."));
|
||||
|
||||
rc = hw_setup_raid(destination);
|
||||
rc = hw_setup_raid(destination, logfile);
|
||||
if (rc) {
|
||||
errorbox(_("Unable to build the RAID."));
|
||||
goto EXIT;
|
||||
@@ -545,7 +543,7 @@ int main(int argc, char *argv[]) {
|
||||
// Execute the partitioning...
|
||||
statuswindow(60, 4, title, _("Partitioning disk..."));
|
||||
|
||||
rc = hw_create_partitions(destination);
|
||||
rc = hw_create_partitions(destination, logfile);
|
||||
if (rc) {
|
||||
errorbox(_("Unable to partition the disk."));
|
||||
goto EXIT;
|
||||
@@ -556,7 +554,7 @@ int main(int argc, char *argv[]) {
|
||||
// Execute the formatting...
|
||||
statuswindow(60, 4, title, _("Creating filesystems..."));
|
||||
|
||||
rc = hw_create_filesystems(destination);
|
||||
rc = hw_create_filesystems(destination, logfile);
|
||||
if (rc) {
|
||||
errorbox(_("Unable to create filesystems."));
|
||||
goto EXIT;
|
||||
@@ -575,7 +573,7 @@ int main(int argc, char *argv[]) {
|
||||
"/bin/tar -C /harddisk -xvf /cdrom/distro.img --lzma 2>/dev/null");
|
||||
|
||||
if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
|
||||
_("Installing the system..."))) {
|
||||
_("Installing the system..."), logfile)) {
|
||||
errorbox(_("Unable to install the system."));
|
||||
goto EXIT;
|
||||
}
|
||||
@@ -592,7 +590,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* Build cache lang file */
|
||||
snprintf(commandstring, STRING_SIZE, "/usr/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");
|
||||
if (runcommandwithstatus(commandstring, title, _("Installing the language cache..."))) {
|
||||
if (runcommandwithstatus(commandstring, title, _("Installing the language cache..."), logfile)) {
|
||||
errorbox(_("Unable to install the language cache."));
|
||||
goto EXIT;
|
||||
}
|
||||
@@ -600,7 +598,7 @@ int main(int argc, char *argv[]) {
|
||||
// Installing bootloader...
|
||||
statuswindow(60, 4, title, _("Installing the bootloader..."));
|
||||
|
||||
rc = hw_install_bootloader(destination);
|
||||
rc = hw_install_bootloader(destination, logfile);
|
||||
if (rc) {
|
||||
errorbox(_("Unable to install the bootloader."));
|
||||
goto EXIT;
|
||||
@@ -627,21 +625,21 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
/* Set marker that the user has already accepted the gpl */
|
||||
mysystem("/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
|
||||
mysystem(logfile, "/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
|
||||
|
||||
/* Copy restore file from cdrom */
|
||||
if (unattended && (strlen(restore_file) > 0)) {
|
||||
fprintf(flog, "unattended: Copy restore file\n");
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"cp /cdrom/%s /harddisk/var/ipfire/backup", restore_file);
|
||||
mysystem(commandstring);
|
||||
mysystem(logfile, commandstring);
|
||||
}
|
||||
|
||||
// Umount source drive and eject
|
||||
hw_umount(SOURCE_MOUNT_PATH);
|
||||
|
||||
snprintf(commandstring, STRING_SIZE, "/usr/bin/eject %s", sourcedrive);
|
||||
mysystem(commandstring);
|
||||
mysystem(logfile, commandstring);
|
||||
|
||||
if (!unattended) {
|
||||
snprintf(message, sizeof(message), _("%s was successfully installed. "
|
||||
@@ -656,7 +654,7 @@ int main(int argc, char *argv[]) {
|
||||
allok = 1;
|
||||
|
||||
EXIT:
|
||||
fprintf(flog, "Install program ended.\n");
|
||||
fprintf(flog, "Install program ended.\n");
|
||||
|
||||
if (!(allok))
|
||||
newtWinMessage(title, _("OK"), _("Press Ok to reboot."));
|
||||
@@ -682,7 +680,7 @@ EXIT:
|
||||
free(destination);
|
||||
}
|
||||
|
||||
hw_stop_all_raid_arrays();
|
||||
hw_stop_all_raid_arrays(logfile);
|
||||
|
||||
if (selected_disks)
|
||||
hw_free_disks(selected_disks);
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
#include "install.h"
|
||||
extern FILE *flog;
|
||||
|
||||
int unattended_setup(struct keyvalue *unattendedkv) {
|
||||
int unattended_setup(struct keyvalue *unattendedkv, const char* output) {
|
||||
FILE* flog = fopen(output, "w+");
|
||||
|
||||
struct keyvalue *mainsettings = initkeyvalues();
|
||||
struct keyvalue *ethernetkv = initkeyvalues();
|
||||
@@ -132,7 +132,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
|
||||
fprintf(flog, "unattended: setting root password\n");
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"/usr/sbin/chroot /harddisk /bin/sh -c \"echo 'root:%s' | /usr/sbin/chpasswd\"", root_password);
|
||||
if (mysystem(commandstring)) {
|
||||
if (mysystem(NULL, commandstring)) {
|
||||
errorbox("unattended: ERROR setting root password");
|
||||
return 0;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
|
||||
fprintf(flog, "unattended: setting admin password\n");
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"/usr/sbin/chroot /harddisk /usr/sbin/htpasswd -c -m -b " CONFIG_ROOT "/auth/users admin '%s'", admin_password);
|
||||
if (mysystem(commandstring)) {
|
||||
if (mysystem(NULL, commandstring)) {
|
||||
errorbox("unattended: ERROR setting admin password");
|
||||
return 0;
|
||||
}
|
||||
@@ -151,11 +151,13 @@ int unattended_setup(struct keyvalue *unattendedkv) {
|
||||
fprintf(flog, "unattended: Restoring Backup\n");
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"/usr/sbin/chroot /harddisk /bin/tar -xvzp -f /var/ipfire/backup/%s -C /", restore_file);
|
||||
if (mysystem(commandstring)) {
|
||||
if (mysystem(NULL, commandstring)) {
|
||||
errorbox("unattended: ERROR restoring backup");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(flog, "unattended: Setup ended\n");
|
||||
fclose(flog);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ struct keyvalue {
|
||||
|
||||
/* libsmooth.c */
|
||||
void stripnl(char *s);
|
||||
int mysystem(const char *command);
|
||||
int mysystem(const char* output, const char *command);
|
||||
void errorbox(char *message);
|
||||
int statuswindowscroll(int width, int height, const char *title, const char *text, ...);
|
||||
int disclaimerbox(char *message);
|
||||
void statuswindow(int width, int height, const char *title, const char *text, ...);
|
||||
int runcommandwithprogress(int width, int height, const char *title, const char *command,
|
||||
int lines, char *text, ...);
|
||||
int runcommandwithstatus(const char *command, const char* title, const char *message);
|
||||
int runhiddencommandwithstatus(const char *command, const char* title, const char *message);
|
||||
int runcommandwithstatus(const char *command, const char* title, const char *message, const char* output);
|
||||
int runhiddencommandwithstatus(const char *command, const char* title, const char *message, const char* output);
|
||||
int checkformodule(const char *module);
|
||||
int replace(char filename1[], char *from, char *to);
|
||||
char* get_version(void);
|
||||
|
||||
@@ -12,11 +12,6 @@
|
||||
#include <libintl.h>
|
||||
#define _(x) dgettext("libsmooth", x)
|
||||
|
||||
extern FILE *flog;
|
||||
extern char *mylog;
|
||||
|
||||
extern char **ctr;
|
||||
|
||||
/* stripnl(). Replaces \n with \0 */
|
||||
void stripnl(char *s) {
|
||||
char *t = strchr(s, '\n');
|
||||
@@ -25,11 +20,17 @@ void stripnl(char *s) {
|
||||
}
|
||||
|
||||
/* Little wrapper. */
|
||||
int mysystem(const char *command) {
|
||||
int mysystem(const char* output, const char *command) {
|
||||
char mycommand[STRING_SIZE];
|
||||
|
||||
snprintf(mycommand, STRING_SIZE, "%s >>%s 2>>%s", command, mylog, mylog);
|
||||
fprintf(flog, "Running command: %s\n", command);
|
||||
if (output == NULL)
|
||||
output = "/dev/null";
|
||||
|
||||
snprintf(mycommand, sizeof(mycommand), "%s >>%s 2>&1", command, output);
|
||||
|
||||
FILE* f = fopen(output, "w+");
|
||||
fprintf(f, "Running command: %s\n", command);
|
||||
fclose(f);
|
||||
|
||||
return system(mycommand);
|
||||
}
|
||||
@@ -71,23 +72,19 @@ void statuswindow(int width, int height, const char *title, const char *text, ..
|
||||
newtFormDestroy(f);
|
||||
}
|
||||
|
||||
int runcommandwithstatus(const char *command, const char* title, const char *message) {
|
||||
int runcommandwithstatus(const char *command, const char* title, const char *message, const char* output) {
|
||||
statuswindow(60, 4, title, message);
|
||||
|
||||
int rc = mysystem(command);
|
||||
int rc = mysystem(output, command);
|
||||
newtPopWindow();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int runhiddencommandwithstatus(const char *command, const char* title, const char *message) {
|
||||
int runhiddencommandwithstatus(const char *command, const char* title, const char *message, const char* output) {
|
||||
statuswindow(60, 4, title, message);
|
||||
|
||||
char mycommand[STRING_SIZE];
|
||||
snprintf(mycommand, STRING_SIZE, "%s >>%s 2>>%s", command, mylog, mylog);
|
||||
fprintf(flog, "Running command: ***** HIDDEN *****\n");
|
||||
|
||||
int rc = system(mycommand);
|
||||
int rc = mysystem(output, command);
|
||||
newtPopWindow();
|
||||
|
||||
return rc;
|
||||
@@ -135,10 +132,7 @@ int runcommandwithprogress(int width, int height, const char *title, const char
|
||||
|
||||
newtDrawForm(f);
|
||||
newtRefresh();
|
||||
|
||||
snprintf(mycommand, STRING_SIZE, "%s 2>>%s", command, mylog);
|
||||
fprintf(flog, "Running command: %s\n", command);
|
||||
|
||||
|
||||
if (!(p = popen(command, "r")))
|
||||
{
|
||||
rc = 1;
|
||||
@@ -146,13 +140,11 @@ int runcommandwithprogress(int width, int height, const char *title, const char
|
||||
}
|
||||
setvbuf(p, NULL, _IOLBF, 255);
|
||||
|
||||
while (fgets(buffer, STRING_SIZE, p))
|
||||
{
|
||||
while (fgets(buffer, STRING_SIZE, p)) {
|
||||
newtScaleSet(s, ++progress);
|
||||
newtRefresh();
|
||||
fprintf(flog, "%s", buffer);
|
||||
}
|
||||
|
||||
|
||||
rc = pclose(p);
|
||||
|
||||
EXIT:
|
||||
@@ -169,7 +161,7 @@ int checkformodule(const char *module) {
|
||||
|
||||
if (!(file = fopen("/proc/modules", "r")))
|
||||
{
|
||||
fprintf(flog, "Unable to open /proc/modules in checkformodule()\n");
|
||||
fprintf(stderr, "Unable to open /proc/modules in checkformodule()\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,13 +209,13 @@ int handledhcp(void)
|
||||
replacekeyvalue(dhcpkv, "ENABLE_GREEN", "on");
|
||||
fclose(fopen(CONFIG_ROOT "/dhcp/enable_green", "w"));
|
||||
chown(CONFIG_ROOT "/dhcp/enable_green", 99, 99);
|
||||
mysystem("/usr/local/bin/dhcpctrl enable");
|
||||
mysystem(NULL, "/usr/local/bin/dhcpctrl enable");
|
||||
}
|
||||
else
|
||||
{
|
||||
replacekeyvalue(dhcpkv, "ENABLE_GREEN", "off");
|
||||
unlink(CONFIG_ROOT "/dhcp/enable_green");
|
||||
mysystem("/usr/local/bin/dhcpctrl disable");
|
||||
mysystem(NULL, "/usr/local/bin/dhcpctrl disable");
|
||||
}
|
||||
replacekeyvalue(dhcpkv, "VALID", "yes");
|
||||
writekeyvalues(dhcpkv, CONFIG_ROOT "/dhcp/settings");
|
||||
@@ -248,7 +248,7 @@ int handledhcp(void)
|
||||
fclose(file);
|
||||
chown(CONFIG_ROOT "/dhcp/dhcpd.conf", 99, 99);
|
||||
if (automode == 0)
|
||||
mysystem("/usr/local/bin/dhcpctrl enable");
|
||||
mysystem(NULL, "/usr/local/bin/dhcpctrl enable");
|
||||
}
|
||||
result = 1;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ int handlekeymap(void)
|
||||
replacekeyvalue(kv, "KEYMAP", keymap);
|
||||
writekeyvalues(kv, CONFIG_ROOT "/main/settings");
|
||||
sprintf(commandstring, "/bin/loadkeys %s", keymap);
|
||||
mysystem(commandstring);
|
||||
mysystem(NULL, commandstring);
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -131,7 +131,7 @@ int writehostsfiles(void)
|
||||
fclose(file);
|
||||
|
||||
sprintf(commandstring, "/bin/hostname %s.%s", hostname, domainname);
|
||||
if (mysystem(commandstring))
|
||||
if (mysystem(NULL, commandstring))
|
||||
{
|
||||
errorbox(_("Unable to set hostname."));
|
||||
return 0;
|
||||
@@ -144,7 +144,7 @@ int handleisdn(void)
|
||||
{
|
||||
char command[STRING_SIZE];
|
||||
sprintf(command, "/etc/rc.d/init.d/mISDN config");
|
||||
if (runcommandwithstatus(command, _("ISDN"), _("Scanning and configuring ISDN devices.")))
|
||||
if (runcommandwithstatus(command, _("ISDN"), _("Scanning and configuring ISDN devices."), NULL))
|
||||
errorbox(_("Unable to scan for ISDN devices."));
|
||||
// Need to write some lines that count the cards and say the names...
|
||||
return 1;
|
||||
|
||||
@@ -422,7 +422,7 @@ int is_interface_up(char *card) { /* Check if the interface is UP */
|
||||
char temp[STRING_SIZE];
|
||||
|
||||
sprintf(temp,"ip link show dev %s | grep -q UP", card);
|
||||
if (mysystem(temp)) return 0; else return 1;
|
||||
if (mysystem(NULL, temp)) return 0; else return 1;
|
||||
}
|
||||
|
||||
int rename_device(char *old_name, char *new_name) {
|
||||
@@ -434,7 +434,7 @@ int rename_device(char *old_name, char *new_name) {
|
||||
return 0;
|
||||
}
|
||||
sprintf(temp,"/sbin/ip link set dev %s name %s",old_name ,new_name );
|
||||
mysystem(temp);
|
||||
mysystem(NULL, temp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -486,14 +486,14 @@ int nic_shutdown(char *nic) {
|
||||
char temp[STRING_SIZE];
|
||||
|
||||
sprintf(temp,"ip link set %s down", nic);
|
||||
mysystem(temp);
|
||||
mysystem(NULL, temp);
|
||||
}
|
||||
|
||||
int nic_startup(char *nic) {
|
||||
char temp[STRING_SIZE];
|
||||
|
||||
sprintf(temp,"ip link set %s up", nic);
|
||||
mysystem(temp);
|
||||
mysystem(NULL, temp);
|
||||
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ int scan_network_cards(void)
|
||||
|
||||
if (!(scanned_nics_read_done))
|
||||
{
|
||||
mysystem("/usr/bin/probenic.sh");
|
||||
mysystem(NULL, "/usr/bin/probenic.sh");
|
||||
if( (fp = fopen(SCANNED_NICS, "r")) == NULL )
|
||||
{
|
||||
fprintf(stderr,"Couldn't open "SCANNED_NICS);
|
||||
@@ -673,12 +673,12 @@ int nicmenu(int colour)
|
||||
_("Select"), _("Identify"), _("Cancel"), NULL);
|
||||
if ( rc == 2 ) {
|
||||
sprintf(temp, "/sbin/ip link set %s up", nics[found_NIC_as_Card[choise]].nic);
|
||||
mysystem(temp);
|
||||
mysystem(NULL, temp);
|
||||
sprintf(temp, "/usr/sbin/ethtool -p %s 10", nics[found_NIC_as_Card[choise]].nic);
|
||||
if (runcommandwithstatus(temp, _("Device Identification"), _("The lights on the selected port should flash now for 10 seconds...")) != 0) {
|
||||
if (runcommandwithstatus(temp, _("Device Identification"), _("The lights on the selected port should flash now for 10 seconds..."), NULL) != 0) {
|
||||
errorbox(_("Identification is not supported by this interface."));
|
||||
sprintf(temp, "/sbin/ip link set %s down", nics[found_NIC_as_Card[choise]].nic);
|
||||
mysystem(temp);
|
||||
mysystem(NULL, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -759,7 +759,7 @@ int manualdriver(char *driver, char *driveroptions)
|
||||
if (strlen(values[0]))
|
||||
{
|
||||
sprintf(commandstring, "/sbin/modprobe %s", values[0]);
|
||||
if (runcommandwithstatus(commandstring, _("Loading module..."), _("Loading module...")) == 0)
|
||||
if (runcommandwithstatus(commandstring, _("Loading module..."), _("Loading module..."), NULL) == 0)
|
||||
{
|
||||
if ((driverend = strchr(values[0], ' ')))
|
||||
{
|
||||
|
||||
@@ -107,12 +107,12 @@ int handlenetworking(void)
|
||||
if (netaddresschange)
|
||||
{
|
||||
runcommandwithstatus("/etc/rc.d/init.d/network stop",
|
||||
_("Networking"), _("Stopping network..."));
|
||||
_("Networking"), _("Stopping network..."), NULL);
|
||||
|
||||
rename_nics();
|
||||
|
||||
runcommandwithstatus("/etc/rc.d/init.d/network start",
|
||||
_("Networking"), _("Restarting network..."));
|
||||
_("Networking"), _("Restarting network..."), NULL);
|
||||
}
|
||||
} else {
|
||||
rename_nics();
|
||||
@@ -445,7 +445,7 @@ int changedrivers(void)
|
||||
}
|
||||
if (automode == 0)
|
||||
runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
|
||||
_("Networking"), _("Restarting non-local network..."));
|
||||
_("Networking"), _("Restarting non-local network..."), NULL);
|
||||
|
||||
findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
|
||||
if (configtype == 1)
|
||||
|
||||
@@ -35,7 +35,7 @@ int handlerootpassword(void)
|
||||
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"/bin/echo 'root:%s' | /usr/sbin/chpasswd", password);
|
||||
if (runhiddencommandwithstatus(commandstring, _("Setting password"), _("Setting 'root' password...."))) {
|
||||
if (runhiddencommandwithstatus(commandstring, _("Setting password"), _("Setting 'root' password...."), NULL)) {
|
||||
errorbox(_("Problem setting 'root' password."));
|
||||
return 0;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ int handleadminpassword(void)
|
||||
snprintf(commandstring, STRING_SIZE,
|
||||
"/usr/sbin/htpasswd -c -m -b " CONFIG_ROOT "/auth/users admin '%s'", password);
|
||||
sprintf(message, _("Setting %s 'admin' user password..."), NAME);
|
||||
if (runhiddencommandwithstatus(commandstring, _("Setting password"), message)) {
|
||||
if (runhiddencommandwithstatus(commandstring, _("Setting password"), message, NULL)) {
|
||||
sprintf(message, _("Problem setting %s 'admin' user password."), NAME);
|
||||
errorbox(message);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user