aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/sledjchisl/sledjchisl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sledjchisl/sledjchisl.c')
-rw-r--r--src/sledjchisl/sledjchisl.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index 96a1cd4..112c297 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -1123,7 +1123,7 @@ struct _simList
1123 // Stuff for the looping through sims, doing things, and waiting. 1123 // Stuff for the looping through sims, doing things, and waiting.
1124 int doIt; 1124 int doIt;
1125 float la; 1125 float la;
1126 char *target; 1126 char *target, *backup;
1127}; 1127};
1128simList *ourSims = NULL; 1128simList *ourSims = NULL;
1129 1129
@@ -1356,6 +1356,7 @@ void freeSimList(simList *sims)
1356 freeLuaTree(sims->simsLua); 1356 freeLuaTree(sims->simsLua);
1357 freeLuaTree(sims->unsorted); 1357 freeLuaTree(sims->unsorted);
1358 free(sims->target); 1358 free(sims->target);
1359 free(sims->backup);
1359 1360
1360 free(sims); 1361 free(sims);
1361} 1362}
@@ -1686,6 +1687,21 @@ int checkSimIsRunning(char *sim)
1686 free(path); 1687 free(path);
1687 return ret; 1688 return ret;
1688} 1689}
1690
1691void findWindow(simData *simd, char *sim, char *type, int count, int window, int panes, int pane)
1692{
1693 snprintf(toybuf, sizeof(toybuf), "%s/IDs_%d.lua", scTemp, window);
1694 qtreetbl_t *IDs = Lua2tree(toybuf, "IDs");
1695 snprintf(toybuf, sizeof(toybuf), "%d %d", window, pane);
1696 simd->paneID = xmprintf("%s", qLuaGet(IDs, toybuf)->v.s);
1697 freeLuaTree(IDs);
1698 if (strcmp(backupIARsim, sim) == 0)
1699 {
1700 ourSims->backup = xstrdup(simd->paneID);
1701 V("Found backup sim %s in %s", sim, simd->paneID);
1702 }
1703}
1704
1689void prepSims(simData *simd, char *sim, char *type, int count, int window, int panes, int pane) 1705void prepSims(simData *simd, char *sim, char *type, int count, int window, int panes, int pane)
1690{ 1706{
1691 char *path = xmprintf("%s/%s.shini", scEtc, simd->tab); 1707 char *path = xmprintf("%s/%s.shini", scEtc, simd->tab);
@@ -1724,12 +1740,7 @@ void prepSims(simData *simd, char *sim, char *type, int count, int window, int p
1724 snprintf(toybuf, sizeof(toybuf), "echo '}\nreturn IDs' >>%s/IDs_%d.lua", scTemp, window); 1740 snprintf(toybuf, sizeof(toybuf), "echo '}\nreturn IDs' >>%s/IDs_%d.lua", scTemp, window);
1725 system(toybuf); 1741 system(toybuf);
1726 1742
1727 snprintf(toybuf, sizeof(toybuf), "%s/IDs_%d.lua", scTemp, window); 1743 findWindow(simd, sim, type, count, window, panes, pane);
1728 qtreetbl_t *IDs = Lua2tree(toybuf, "IDs");
1729 snprintf(toybuf, sizeof(toybuf), "%d %d", window, pane);
1730 simd->paneID = xmprintf("%s", qLuaGet(IDs, toybuf)->v.s);
1731 freeLuaTree(IDs);
1732
1733 simd->portH = 8004 + count * 2; 1744 simd->portH = 8004 + count * 2;
1734 simd->portU = 8005 + count * 2; 1745 simd->portU = 8005 + count * 2;
1735 cmd = xmprintf("rm -fr %s/sim%d; mkdir -p %s/sim%d; sed -E" 1746 cmd = xmprintf("rm -fr %s/sim%d; mkdir -p %s/sim%d; sed -E"
@@ -1888,7 +1899,27 @@ byTab has the short name as the key, simData as the value.
1888 strftime(date, DATE_TIME_LEN, "%F_%T", localtime(&curtime)); 1899 strftime(date, DATE_TIME_LEN, "%F_%T", localtime(&curtime));
1889 if (FLAG(m)) 1900 if (FLAG(m))
1890 { 1901 {
1891 I("Member %s is being backed up to %s/backups/%s-%s.iar.", sim, scRoot, sim, date); 1902 char *last = strchr(sim, ' ');
1903
1904 last[0] = '\0'; last++;
1905// TODO - double check it's a real member.
1906 I("Member %s %s is being backed up to %s/backups/%s_%s-%s.iar in tmux windo %s.", sim, last, scRoot, sim, last, date, ourSims->backup);
1907 snprintf(toybuf, sizeof(toybuf), "save iar -c %s %s / password %s/backups/%s_%s-%s.iar", sim, last, scRoot, sim, last, date);
1908 if (NULL != ourSims->backup)
1909 {
1910 sendTmuxCmd(ourSims->backup, toybuf);
1911// if (0 == do)
1912 {
1913 snprintf(toybuf, sizeof(toybuf), "Saved archive with [[:digit:]]+ items for %s %s", sim, last);
1914 waitTmuxText(ourSims->backup, toybuf);
1915 I("%s is done backing up.", simd->name);
1916// TODO - should delete / gitAR the old ones now.
1917// Have a config option for delete / gitAR / rsync.
1918 ourSims->la = waitLoadAverage(ourSims->la, loadAverageInc, simTimeOut);
1919 }
1920 }
1921 else
1922 E("Can't find backup sim.");
1892 } 1923 }
1893 else if (checkSimIsRunning(simd->tab)) 1924 else if (checkSimIsRunning(simd->tab))
1894 { 1925 {
@@ -7991,6 +8022,7 @@ V("Doing %s for %s '%s' %s %s", modeStrings[currentMode], FLAG(m) ? "member" :
7991 { 8022 {
7992 // Do stuff with the members. 8023 // Do stuff with the members.
7993 ourSims->doIt = 1; 8024 ourSims->doIt = 1;
8025 forEachSim("Doing", findWindow, NULL);
7994 forEachMember("Doing", doSimsThing, NULL); 8026 forEachMember("Doing", doSimsThing, NULL);
7995 } 8027 }
7996 else 8028 else