]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/install+setup/install/unattended.c
daq: Update to 2.0.4
[ipfire-2.x.git] / src / install+setup / install / unattended.c
index d7ff113a9fd320c55f0419e774d2443b70768564..77e1eabbdc94f95d564173d14fa2504034992fd1 100644 (file)
@@ -15,7 +15,7 @@
  * along with IPFire; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
- * Copyright 2002: Mark Wormgoor <mark@wormgoor.com>
+ * Copyright 2007: Michael Tremer for www.ipfire.org
  * 
  */
 
@@ -41,6 +41,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
     char green_broadcast[STRING_SIZE];
     char root_password[STRING_SIZE];
     char admin_password[STRING_SIZE];
+    char restore_file[STRING_SIZE] = "";
 
     findkey(unattendedkv, "DOMAINNAME", domainname);
     findkey(unattendedkv, "HOSTNAME", hostname);
@@ -54,6 +55,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
     findkey(unattendedkv, "GREEN_BROADCAST", green_broadcast);
     findkey(unattendedkv, "ROOT_PASSWORD", root_password);
     findkey(unattendedkv, "ADMIN_PASSWORD", admin_password);
+    findkey(unattendedkv, "RESTORE_FILE", restore_file);
 
     /* write main/settings. */
     replacekeyvalue(mainsettings, "DOMAINNAME", domainname);
@@ -129,7 +131,7 @@ int unattended_setup(struct keyvalue *unattendedkv) {
     /* set root password */
     fprintf(flog, "unattended: setting root password\n");
     snprintf(commandstring, STRING_SIZE,
-           "/sbin/chroot /harddisk /bin/sh -c \"echo 'root:%s' | /usr/sbin/chpasswd\"", root_password);
+           "/usr/sbin/chroot /harddisk /bin/sh -c \"echo 'root:%s' | /usr/sbin/chpasswd\"", root_password);
     if (mysystem(commandstring)) {
        errorbox("unattended: ERROR setting root password");
        return 0;
@@ -138,12 +140,22 @@ int unattended_setup(struct keyvalue *unattendedkv) {
     /* set admin password */
     fprintf(flog, "unattended: setting admin password\n");
     snprintf(commandstring, STRING_SIZE,
-           "/sbin/chroot /harddisk /usr/sbin/htpasswd -c -m -b " CONFIG_ROOT "/auth/users admin '%s'", admin_password);
+           "/usr/sbin/chroot /harddisk /usr/sbin/htpasswd -c -m -b " CONFIG_ROOT "/auth/users admin '%s'", admin_password);
     if (mysystem(commandstring)) {
        errorbox("unattended: ERROR setting admin password");
        return 0;
     }
 
+       /* restore backup */
+       if (strlen(restore_file) > 0) {
+               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)) {
+               errorbox("unattended: ERROR restoring backup");
+           }
+       }
+
     fprintf(flog, "unattended: Setup ended\n");
     return 1;
 }