[PATCH 13/16] Update restart-anaconda to work with systemd.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 loader/loader.c          |   39 +++++++++++++++++++++++++--------------
 scripts/restart-anaconda |   29 ++++-------------------------
 2 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index 4365e40..79c1b8c 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1778,19 +1778,25 @@ void loaderUsrXHandler(int signum) {
     init_sig = signum;
 }
 
-int restart_anaconda(struct loaderData_s *loaderData) {
+void restart_anaconda(struct loaderData_s *loaderData) {
     if (access("/tmp/restart_anaconda", R_OK))
-        return 0;
+        return;
+
     puts("Restarting Anaconda.");
     unlink("/tmp/restart_anaconda");
-    if (loaderData->updatessrc) {
+
+    if (!access("/var/run/loader.run", R_OK))
+        unlink("/var/run/loader.run");
+
+    if (loaderData && loaderData->updatessrc) {
         int updates_fd = open("/tmp/updates", O_RDONLY);
         if (recursiveRemove(updates_fd))
             fprintf(stderr, "Error removing /tmp/updates. Updates won't be re-downloaded.");
         else
             loadUpdatesFromRemote(loaderData->updatessrc, loaderData);
     }
-    return 1;
+
+    return;
 }
 
 static int anaconda_trace_init(int isDevelMode) {
@@ -1977,16 +1983,6 @@ int main(int argc, char ** argv) {
     rc = anaconda_trace_init(isDevelMode);
     setupEnv();
 
-    if (!access("/var/run/loader.run", R_OK)) {
-        printf(_("loader has already been run.  Starting shell.\n"));
-        execl("/bin/sh", "-/bin/sh", NULL);
-        doExit(0);
-    }
-
-    f = fopen("/var/run/loader.run", "w+");
-    fprintf(f, "%d\n", getpid());
-    fclose(f);
-
     /* uncomment to send mac address in ks=http:/ header by default*/
     flags |= LOADER_FLAGS_KICKSTART_SEND_MAC;
 
@@ -2012,6 +2008,21 @@ int main(int argc, char ** argv) {
     extraArgs[0] = NULL;
     parseCmdLineFlags(&loaderData);
 
+    /* If the anaconda process is now being restarted, we need to do some
+     * environment cleanup first.
+     */
+    restart_anaconda(&loaderData);
+
+    if (!access("/var/run/loader.run", R_OK)) {
+        printf(_("loader has already been run.  Starting shell.\n"));
+        execl("/bin/sh", "-/bin/sh", NULL);
+        doExit(0);
+    }
+
+    f = fopen("/var/run/loader.run", "w+");
+    fprintf(f, "%d\n", getpid());
+    fclose(f);
+
     logMessage(INFO, "anaconda version %s on %s starting", VERSION, getProductArch());
 
     init_serial(&orig_cmode, &orig_flags, cmdline);
diff --git a/scripts/restart-anaconda b/scripts/restart-anaconda
index 8a82b51..639e47a 100755
--- a/scripts/restart-anaconda
+++ b/scripts/restart-anaconda
@@ -20,38 +20,17 @@
 #
 
 RESTART_FILE=/tmp/restart_anaconda
-ANACONDA_PID=`cat /var/run/anaconda.pid`
-
-descendants() {
-    PID=$1
-    DIRECT=`ps --ppid $PID -o pid=`
-    INDIRECT=''
-    for child in $DIRECT; do
-	INDIRECT+=' '`descendants $child`
-    done
-    # prepend grandchildren, we are goingt to kill them first  
-    DESCENDANTS=$INDIRECT' '$DIRECT
-    echo $DESCENDANTS
-}
-
-anaconda_descendants() {
-    descendants $ANACONDA_PID
-}
 
 # this is how loader knows it should restart stuff. 
 # it will also delete the file once the restart is in progress.
 touch $RESTART_FILE
 
-# kill all anaconda descendants and anaconda itself
-RESTART_VICTIMS=`anaconda_descendants`
-RESTART_VICTIMS+=' '$ANACONDA_PID
 if [[ -f /var/run/iscsid.pid ]]; then
     # iscsid must die else it will cause us troubles on the next run
-    RESTART_VICTIMS+=' '`cat /var/run/iscsid.pid`
     # log out of all nodes
     /sbin/iscsiadm -m node --logoutall=all
 fi
-echo "killing processes: " $RESTART_VICTIMS
-for child in $RESTART_VICTIMS; do
-    kill -s KILL $child &>/dev/null
-done
+
+# This will kill all programs in the loader group and restart the
+# service.
+systemctl restart loader.service
-- 
1.7.4.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux