| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 3 | * 2013-2024 by the Falcon Player Developers. | ||
| 4 | * | ||
| 5 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 6 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 7 | * file for descriptions of what files are covered by each license. | ||
| 8 | * | ||
| 9 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 10 | * included LICENSE.LGPL file. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <array> | ||
| 14 | #include "fpp-json.h" | ||
| 15 | #include <chrono> | ||
| 16 | #include <cctype> | ||
| 17 | #include <cstdio> | ||
| 18 | #include <cstdlib> | ||
| 19 | #include <cstring> | ||
| 20 | #include <ctime> | ||
| 21 | #include <dirent.h> | ||
| 22 | #include <fcntl.h> | ||
| 23 | #include <memory> | ||
| 24 | #include <pwd.h> | ||
| 25 | #include <sys/stat.h> | ||
| 26 | #include <systemd/sd-daemon.h> | ||
| 27 | #include <thread> | ||
| 28 | #include <unistd.h> | ||
| 29 | |||
| 30 | #include "FPPINIT.h" | ||
| 31 | |||
| 32 | // teeOutput() -- which sends our stdout, and that of everything we fork, to both | ||
| 33 | // fppd.log and the console we were started with -- now lives in common_mini.cpp | ||
| 34 | // so fpprtc (which links common_mini but not FPPINIT) can use it too. | ||
| 35 | |||
| 36 | 4 | int remove_recursive(const char* const path, bool removeThis = true) { | |
| 37 | 4 | DIR* const directory = opendir(path); | |
| 38 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (directory) { |
| 39 | struct dirent* entry; | ||
| 40 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4 times.
|
13 | while ((entry = readdir(directory))) { |
| 41 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) { |
| 42 | 8 | continue; | |
| 43 | } | ||
| 44 | 1 | char filename[strlen(path) + strlen(entry->d_name) + 2]; | |
| 45 | 1 | sprintf(filename, "%s/%s", path, entry->d_name); | |
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (entry->d_type == DT_DIR) { |
| 47 | ✗ | if (remove_recursive(filename)) { | |
| 48 | ✗ | closedir(directory); | |
| 49 | ✗ | return -1; | |
| 50 | } | ||
| 51 | } else { | ||
| 52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (remove(filename)) { |
| 53 | ✗ | closedir(directory); | |
| 54 | ✗ | return -1; | |
| 55 | } | ||
| 56 | } | ||
| 57 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
|
9 | } |
| 58 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (closedir(directory)) { |
| 59 | ✗ | return -1; | |
| 60 | } | ||
| 61 | } | ||
| 62 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (removeThis) { |
| 63 | ✗ | return remove(path); | |
| 64 | } | ||
| 65 | 4 | return 0; | |
| 66 | } | ||
| 67 | |||
| 68 | 1582 | void exec(const std::string& cmd) { | |
| 69 | std::array<char, 128> buffer; | ||
| 70 | struct PipeCloser { | ||
| 71 | 1582 | void operator()(FILE* f) const { | |
| 72 |
1/2✓ Branch 0 taken 1582 times.
✗ Branch 1 not taken.
|
1582 | if (f) |
| 73 | 1582 | pclose(f); | |
| 74 | 1582 | } | |
| 75 | }; | ||
| 76 |
1/2✓ Branch 0 taken 1582 times.
✗ Branch 1 not taken.
|
1582 | std::unique_ptr<FILE, PipeCloser> pipe(popen(cmd.c_str(), "r")); |
| 77 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1582 times.
|
1582 | if (!pipe) { |
| 78 | ✗ | throw std::runtime_error("popen() failed!"); | |
| 79 | } | ||
| 80 |
3/4✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1582 times.
|
4798 | while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { |
| 81 |
1/2✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
|
23 | printf("%s", buffer.data()); |
| 82 | } | ||
| 83 | 1582 | } | |
| 84 | 204 | bool isShellSafeWord(const std::string& s) { | |
| 85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
|
204 | if (s.empty()) { |
| 86 | ✗ | return false; | |
| 87 | } | ||
| 88 |
2/2✓ Branch 0 taken 810 times.
✓ Branch 1 taken 203 times.
|
1013 | for (char c : s) { |
| 89 |
9/12✓ Branch 0 taken 9 times.
✓ Branch 1 taken 801 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
810 | if (!isalnum((unsigned char)c) && c != '.' && c != '_' && c != '/' && c != '+' && c != '-') { |
| 90 | 1 | return false; | |
| 91 | } | ||
| 92 | } | ||
| 93 | 203 | return true; | |
| 94 | } | ||
| 95 | 219 | int execbg(const std::string& cmd) { | |
| 96 | 219 | return system(cmd.c_str()); | |
| 97 | } | ||
| 98 | 6004 | std::string execAndReturn(const std::string& cmd) { | |
| 99 | std::array<char, 128> buffer; | ||
| 100 | struct PipeCloser { | ||
| 101 | 6004 | void operator()(FILE* f) const { | |
| 102 |
1/2✓ Branch 0 taken 6004 times.
✗ Branch 1 not taken.
|
6004 | if (f) |
| 103 | 6004 | pclose(f); | |
| 104 | 6004 | } | |
| 105 | }; | ||
| 106 |
1/2✓ Branch 0 taken 6004 times.
✗ Branch 1 not taken.
|
6004 | std::unique_ptr<FILE, PipeCloser> pipe(popen(cmd.c_str(), "r")); |
| 107 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6004 times.
|
6004 | if (!pipe) { |
| 108 | ✗ | throw std::runtime_error("popen() failed!"); | |
| 109 | } | ||
| 110 | 6004 | std::string ret; | |
| 111 |
3/4✓ Branch 0 taken 8032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2028 times.
✓ Branch 3 taken 6004 times.
|
22970 | while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { |
| 112 |
2/4✓ Branch 0 taken 2028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2028 times.
✗ Branch 3 not taken.
|
5182 | ret += std::string(buffer.data()); |
| 113 | } | ||
| 114 | 6004 | return ret; | |
| 115 | 6004 | } | |
| 116 | |||
| 117 | 276 | bool LoadJsonFromString(const std::string& str, Json::Value& root) { | |
| 118 |
1/2✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
|
276 | Json::CharReaderBuilder builder; |
| 119 |
1/2✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
|
276 | Json::CharReader* reader = builder.newCharReader(); |
| 120 | 276 | std::string errors; | |
| 121 |
3/6✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
|
828 | builder["collectComments"] = false; |
| 122 |
2/2✓ Branch 0 taken 274 times.
✓ Branch 1 taken 2 times.
|
276 | bool success = reader->parse(str.c_str(), str.c_str() + str.size(), &root, &errors); |
| 123 |
1/2✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
|
274 | delete reader; |
| 124 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 272 times.
|
274 | if (!success) { |
| 125 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | Json::Value empty; |
| 126 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | root = empty; |
| 127 | 2 | return false; | |
| 128 | 2 | } | |
| 129 | 272 | return true; | |
| 130 | 278 | } | |
| 131 | |||
| 132 | // A file that parses cleanly but holds the wrong kind of root - an array where | ||
| 133 | // an object is expected, or the reverse - is a corrupt config, not usable data. | ||
| 134 | // Every jsoncpp accessor a caller reaches for next (operator[], isMember(), | ||
| 135 | // getMemberNames(), get()) throws Json::LogicError on that mismatch, and | ||
| 136 | // fppinit has no systemd Restart=, so a bad config file here doesn't restart | ||
| 137 | // a daemon, it kills boot. This mirrors the JsonRoot check on FPP's own | ||
| 138 | // loader in common.cpp; it is duplicated rather than shared because fppinit | ||
| 139 | // does not pull in common.h. | ||
| 140 | 258 | bool LoadJsonFromString(const std::string& str, Json::Value& root, JsonRoot expected) { | |
| 141 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 247 times.
|
258 | Json::ValueType expectedType = (expected == JsonRoot::Array) ? Json::arrayValue : Json::objectValue; |
| 142 | |||
| 143 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 254 times.
|
258 | if (!LoadJsonFromString(str, root)) { |
| 144 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | root = Json::Value(expectedType); |
| 145 | 2 | return false; | |
| 146 | } | ||
| 147 | |||
| 148 | // A null root is not a mismatch - jsoncpp treats null as an empty value of | ||
| 149 | // whatever type it is first used as and never throws on it. | ||
| 150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
|
254 | if (root.isNull()) { |
| 151 | ✗ | root = Json::Value(expectedType); | |
| 152 | ✗ | return true; | |
| 153 | } | ||
| 154 | |||
| 155 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 253 times.
|
254 | if (root.type() != expectedType) { |
| 156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | printf("JSON string has the wrong root type, expected %s - treating as empty\n", |
| 157 | (expectedType == Json::arrayValue) ? "array" : "object"); | ||
| 158 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | root = Json::Value(expectedType); |
| 159 | 1 | return false; | |
| 160 | } | ||
| 161 | |||
| 162 | 253 | return true; | |
| 163 | } | ||
| 164 | 196 | std::string SaveJsonToString(const Json::Value& root) { | |
| 165 |
1/2✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
|
196 | Json::StreamWriterBuilder wbuilder; |
| 166 |
3/6✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 196 times.
✗ Branch 5 not taken.
|
588 | wbuilder["indentation"] = "\t"; |
| 167 | |||
| 168 |
1/2✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
|
196 | std::string result = Json::writeString(wbuilder, root); |
| 169 | |||
| 170 | 196 | return result; | |
| 171 | 196 | } | |
| 172 | |||
| 173 | 56 | void modprobe(const char* mod) { | |
| 174 |
2/4✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
|
56 | std::string cmd = std::string("/usr/sbin/modprobe ") + mod; |
| 175 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
56 | exec(cmd); |
| 176 | 56 | } | |
| 177 | |||
| 178 | // Once per boot (or a manual "fppinit start"), not from bootPre, which every | ||
| 179 | // fppd restart runs: lets the update-activity API end a run opened before this | ||
| 180 | // boot without trusting the clock (#3187). Never creates the log. | ||
| 181 | 39 | static void logBootToUpgradeLog() { | |
| 182 |
2/4✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | std::string bootId = GetFileContents("/proc/sys/kernel/random/boot_id"); |
| 183 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | TrimWhiteSpace(bootId); |
| 184 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | std::string logFile = FPP_MEDIA_DIR + "/logs/fpp_system_upgrades.log"; |
| 185 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
|
39 | if (bootId.empty()) { |
| 186 | ✗ | return; | |
| 187 | } | ||
| 188 | // O_NOFOLLOW/O_NONBLOCK + S_ISREG: a symlink or FIFO there must not hang boot. | ||
| 189 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | int fd = open(logFile.c_str(), O_WRONLY | O_APPEND | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC); |
| 190 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
|
39 | if (fd < 0) { |
| 191 | 37 | return; | |
| 192 | } | ||
| 193 | struct stat st; | ||
| 194 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | if (fstat(fd, &st) != 0 || !S_ISREG(st.st_mode)) { |
| 195 | ✗ | close(fd); | |
| 196 | ✗ | return; | |
| 197 | } | ||
| 198 | char stamp[32]; | ||
| 199 | 2 | time_t now = time(nullptr); | |
| 200 | 2 | strftime(stamp, sizeof(stamp), "%Y-%m-%d %H:%M:%S", localtime(&now)); | |
| 201 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
2 | std::string line = std::string(stamp) + " [fpp-boot " + bootId + "] System booted (clock may not be synced yet)\n"; |
| 202 |
6/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
|
2 | if (write(fd, line.c_str(), line.size()) == (ssize_t)line.size() && st.st_mtime > now) { |
| 203 | // A clock that came up behind (no RTC) would move the mtime backwards, and | ||
| 204 | // an open browser tab drops payloads older than the last one it applied. | ||
| 205 | 1 | struct timespec times[2] = { { 0, UTIME_OMIT }, { st.st_mtime + 1, 0 } }; | |
| 206 | 1 | futimens(fd, times); | |
| 207 | } | ||
| 208 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | close(fd); |
| 209 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | printf("FPP - Logged boot to the upgrade log\n"); |
| 210 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37 times.
|
76 | } |
| 211 | |||
| 212 | 268 | int main(int argc, char* argv[]) { | |
| 213 | // Everything fppinit runs, it runs to parse: aplay, arecord, amixer and | ||
| 214 | // the network tools all translate their output, and systemd hands every | ||
| 215 | // service the system locale. Under fr_FR "aplay -l" lists "carte 0:", | ||
| 216 | // and the audio setup found no sound card at all. C.UTF-8 keeps UTF-8 | ||
| 217 | // file names intact and has no translations. | ||
| 218 | 268 | setenv("LC_ALL", "C.UTF-8", 1); | |
| 219 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | std::string networkSetupMut = FPP_MEDIA_DIR + "/tmp/networkSetup"; |
| 220 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | std::string action = "start"; |
| 221 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | if (argc > 1) { |
| 222 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | action = argv[1]; |
| 223 | } | ||
| 224 | // Both actions now log to the shared fppd.log (was fpp_init.log / | ||
| 225 | // fpp_boot.log); the facility keeps them apart within the file. Same | ||
| 226 | // directory as before, so the retry below still covers the same failure -- | ||
| 227 | // media/logs not yet mounted or writable on a first/degraded boot. | ||
| 228 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | std::string logFile = FPP_MEDIA_DIR + "/logs/fppd.log"; |
| 229 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | FILE* f = fopen(logFile.c_str(), "a+"); |
| 230 | 268 | int sleepCount = 0; | |
| 231 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
268 | while (!f && sleepCount < 30) { |
| 232 | ✗ | printf("Could not open log\n"); | |
| 233 | ✗ | sleepCount++; | |
| 234 | ✗ | std::this_thread::sleep_for(std::chrono::milliseconds(100)); | |
| 235 | ✗ | f = fopen(logFile.c_str(), "a+"); | |
| 236 | } | ||
| 237 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | if (f) { |
| 238 | // This fopen is the first thing to touch fppd.log on a box where it does | ||
| 239 | // not exist -- fppinit bootPre is fppd.service's ExecStartPre, so it gets | ||
| 240 | // there before fppd itself -- and we run as root, so the file would be | ||
| 241 | // left root:root 0644 in an fpp-owned directory. fppd.log is no longer | ||
| 242 | // fppd's alone: the fppd_start/stop/restart scripts append to it, and so | ||
| 243 | // do the PHP breadcrumbs (backup, mp3gain) which run as Apache/fpp. Their | ||
| 244 | // writes are error-suppressed best-effort, so they would fail SILENTLY. | ||
| 245 | // Whoever creates the file owns making it writable by fpp; here, that is | ||
| 246 | // us. (log.cpp does the same for the case where fppd creates it first, | ||
| 247 | // and logrotate's `create 0664 fpp fpp` covers the rotation case.) | ||
| 248 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | struct passwd* pw = getpwnam("fpp"); |
| 249 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 193 times.
|
268 | if (pw) { |
| 250 |
1/2✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
|
75 | if (fchown(fileno(f), pw->pw_uid, pw->pw_gid) == 0) { |
| 251 | 75 | fchmod(fileno(f), 0664); | |
| 252 | } | ||
| 253 | } | ||
| 254 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | fclose(f); |
| 255 | // Every fppinit invocation that produces output goes to fppd.log. The | ||
| 256 | // facility names the phase (fppinit is the program field, so the phase is | ||
| 257 | // the only thing distinguishing one invocation from another); they are | ||
| 258 | // deliberately NOT fppd facilities from log.h -- fppinit is not fppd. | ||
| 259 | // | ||
| 260 | // bootPre/bootPost are fppd.service's ExecStartPre/ExecStartPost. They | ||
| 261 | // were the last FPP output still escaping to journald -- the boot banners, | ||
| 262 | // cape/eeprom detection and sysctl settings, which teeOutput's dup2 picks | ||
| 263 | // up because they come from processes fppinit forks. That output is real | ||
| 264 | // diagnostic content and journald here is RAM-only (/run/log/journal), so | ||
| 265 | // it died at reboot and never reached a Support Zip. | ||
| 266 |
3/4✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 229 times.
|
268 | if (action == "start") { |
| 267 |
3/6✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
|
193 | teeOutput(logFile, "fppinit", "Startup", getpid()); |
| 268 |
3/4✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 192 times.
|
229 | } else if (action == "postNetwork") { |
| 269 |
3/6✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
|
185 | teeOutput(logFile, "fppinit", "Boot", getpid()); |
| 270 |
3/4✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 189 times.
|
192 | } else if (action == "bootPre") { |
| 271 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
15 | teeOutput(logFile, "fppinit", "BootPre", getpid()); |
| 272 |
2/4✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
|
189 | } else if (action == "bootPost") { |
| 273 | ✗ | teeOutput(logFile, "fppinit", "BootPost", getpid()); | |
| 274 |
11/18✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 186 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 186 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 186 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 186 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 186 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 186 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 186 times.
|
189 | } else if (action == "runPreStartScripts" || action == "runPostStartScripts" || action == "runPreStopScripts" || action == "runPostStopScripts") { |
| 275 | // Standalone equivalents of the runScripts() calls inside start/ | ||
| 276 | // bootPre/bootPost (already teed there); not currently invoked by | ||
| 277 | // anything shipped in this repo, but if a plugin or admin script | ||
| 278 | // ever calls `fppinit runPreStartScripts` etc. directly, its output | ||
| 279 | // - and now, which plugin/UserCallbackHook scripts it found and ran - | ||
| 280 | // should land in fppd.log rather than nowhere. | ||
| 281 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
15 | teeOutput(logFile, "fppinit", "Scripts", getpid()); |
| 282 |
13/18✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 133 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 133 times.
✓ Branch 16 taken 53 times.
✓ Branch 17 taken 133 times.
|
186 | } else if (action == "setupNetwork" || action == "checkForTether" || action == "maybeRemoveTether" || action == "applyNTPFromDHCP") { |
| 283 | // These drive AP<->client WiFi transitions (the interactive "Restart | ||
| 284 | // Network" apply, and the networkd-dispatcher-triggered tether | ||
| 285 | // watchdog/removal). Without this, their output only reaches | ||
| 286 | // journald (setupNetwork's is captured by the PHP caller and shown | ||
| 287 | // in the browser, but never persisted) or the networkd-dispatcher | ||
| 288 | // process's own syslog lines - invisible to fppd.log either way, | ||
| 289 | // even though this is exactly the sequence a WiFi-setup bug report | ||
| 290 | // needs to reconstruct. | ||
| 291 |
3/6✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
|
263 | teeOutput(logFile, "fppinit", "Network", getpid()); |
| 292 |
3/4✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 50 times.
|
133 | } else if (action == "setupAudio") { |
| 293 | // Backgrounded by settings.php with its stdout/stderr explicitly sent | ||
| 294 | // to /dev/null so the HTTP response returns immediately - teeOutput's | ||
| 295 | // dup2 replaces that fd before we print anything, so this capture | ||
| 296 | // still works even though the parent shell redirected us away. | ||
| 297 |
3/6✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
|
380 | teeOutput(logFile, "fppinit", "Audio", getpid()); |
| 298 |
17/26✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 40 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 40 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 40 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 37 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 34 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 34 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 33 times.
✓ Branch 21 taken 1 times.
✓ Branch 22 taken 33 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 29 times.
✓ Branch 25 taken 4 times.
|
90 | } else if (action == "configureBBB" || action == "applyThermal" || action == "resetThermal" || action == "installKiosk" || action == "setupPiRTC" || action == "setupHDMICEC" || action == "setupWifiAntenna" || |
| 299 |
7/12✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✗ Branch 11 not taken.
|
29 | action == "setupChannelOutputs" || action == "checkConfigMigrations" || action == "detectCape" || |
| 300 |
12/16✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 43 times.
✓ Branch 15 taken 7 times.
|
90 | action == "setupTimezone" || action == "checkHostName" || action == "handleBootActions") { |
| 301 | // Same gap as setupNetwork: invoked directly via PHP exec(), output | ||
| 302 | // otherwise lives only in that request's $output/HTTP response. | ||
| 303 |
3/6✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
|
182 | teeOutput(logFile, "fppinit", "Config", getpid()); |
| 304 |
8/10✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 4 times.
|
7 | } else if (action == "announceIP" || action == "resizeRootFS") { |
| 305 | // One-shot systemd services (fpp-announce-ip / fpp-expand-rootfs); | ||
| 306 | // same RAM-only-journald loss as bootPre/bootPost before they were | ||
| 307 | // added above. | ||
| 308 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
15 | teeOutput(logFile, "fppinit", "Boot", getpid()); |
| 309 |
3/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
|
4 | } else if (action == "reboot") { |
| 310 | // fpp-reboot.service - capture why/what before the box actually goes | ||
| 311 | // down, so it's the last thing in fppd.log rather than nothing. | ||
| 312 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
4 | teeOutput(logFile, "fppinit", "Reboot", getpid()); |
| 313 | } | ||
| 314 | } else { | ||
| 315 | ✗ | printf("Could not too output to log. Directory might not be writable or maybe full.\n"); | |
| 316 | } | ||
| 317 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | printf("------------------------------\nRunning FPPINIT %s", action.c_str()); |
| 318 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 268 times.
|
280 | for (int x = 2; x < argc; x++) { |
| 319 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | printf(" %s", argv[x]); |
| 320 | } | ||
| 321 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | printf("\n"); |
| 322 |
3/4✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 229 times.
|
268 | if (action == "start") { |
| 323 | // www/common.php caches the system UUID and its source here and treats | ||
| 324 | // the cache as once-per-boot. In a container /tmp is the writable layer | ||
| 325 | // and survives restarts and in-place upgrades, so a UUID an older | ||
| 326 | // scripts/get_uuid took from the image's shared machine-id was being | ||
| 327 | // served for good, even after get_uuid stopped producing it. Drop both | ||
| 328 | // so each start asks the current get_uuid again. | ||
| 329 | 39 | unlink("/tmp/fpp_uuid"); | |
| 330 | 39 | unlink("/tmp/fpp_uuid_source"); | |
| 331 |
3/4✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 35 times.
|
39 | if (!FileExists("/etc/fpp/container")) { |
| 332 | #ifdef CAPEDETECT | ||
| 333 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | printf("FPP - Cleaning tmp\n"); |
| 334 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | remove_recursive((FPP_MEDIA_DIR + "/tmp/").c_str(), false); |
| 335 | #endif | ||
| 336 | } | ||
| 337 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | createDirectories(); |
| 338 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | printf("FPP - Directories created\n"); |
| 339 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | bool needReboot = checkUnpartitionedSpace(); |
| 340 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | checkSSHKeys(); |
| 341 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | handleBootPartition(); |
| 342 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | checkHostName(); |
| 343 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | checkFSTAB(); |
| 344 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupApache(); |
| 345 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | DetectCape(); |
| 346 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupTimezone(); |
| 347 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | logBootToUpgradeLog(); |
| 348 | // After DetectCape() above, so a cape shipping DisablePiRTC in its | ||
| 349 | // defaultSettings is honoured on the boot it is first detected on. | ||
| 350 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupPiRTCConfig(); |
| 351 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupHDMICECConfig(); |
| 352 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupWifiAntennaConfig(); |
| 353 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setup16KPageKernel(); |
| 354 |
2/4✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | int reboot = getRawSettingInt("rebootFlag", 0); |
| 355 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
39 | if (reboot && !needReboot) { |
| 356 | ✗ | printf("FPP - Clearing reboot flags\n"); | |
| 357 | ✗ | setRawSetting("rebootFlag", "0"); | |
| 358 | } | ||
| 359 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | handleBootActions(); |
| 360 |
2/4✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | runScripts("boot", true); |
| 361 |
7/18✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 39 times.
✓ Branch 10 taken 39 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 39 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
78 | int skipNetwork = FileExists("/etc/fpp/desktop") || getRawSettingInt("SkipNetworkReset", 0); |
| 362 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | if (!skipNetwork) { |
| 363 | // Respect the same "FPP doesn't own networking here" gate as | ||
| 364 | // setupNetwork() below -- this touches the same | ||
| 365 | // systemd-networkd-owned lease state, so it must not run on | ||
| 366 | // desktop/dev builds or when the admin has explicitly opted out | ||
| 367 | // via SkipNetworkReset. | ||
| 368 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | consumePendingDhcpLeaseReset(); |
| 369 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupNetwork(); |
| 370 | } | ||
| 371 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | configureBBB(); |
| 372 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | applyThermalSettings(true); |
| 373 | // Probe each fan's tachometer (forces it on briefly) so fppd can hide | ||
| 374 | // the RPM for a fan it can't detect. Must run before fppd starts. | ||
| 375 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | probeFanPresence(); |
| 376 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupChannelOutputs(); |
| 377 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setupKiosk(); |
| 378 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | printf("Setting file ownership\n"); |
| 379 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | setFileOwnership(); |
| 380 |
3/6✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
|
43 | PutFileContents(FPP_MEDIA_DIR + "/tmp/cape_detect_done", "1"); |
| 381 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | checkInstallKiosk(); |
| 382 | |||
| 383 |
3/4✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 35 times.
|
39 | if (!FileExists("/etc/fpp/container")) { |
| 384 | // Create boot delay flag file early if boot delay is configured | ||
| 385 | // so UI can show warning immediately when Apache starts | ||
| 386 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | int bootDelaySetting = getRawSettingInt("bootDelay", -1); |
| 387 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (bootDelaySetting != 0) { |
| 388 | // Store start time and duration/mode for UI countdown | ||
| 389 | 4 | time_t startTime = time(nullptr); | |
| 390 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | if (bootDelaySetting > 0) { |
| 391 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::string flagContent = std::to_string(startTime) + "," + std::to_string(bootDelaySetting); |
| 392 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | PutFileContents(FPP_MEDIA_DIR + "/tmp/boot_delay", flagContent); |
| 393 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
4 | } else if (bootDelaySetting == -1) { |
| 394 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | std::string flagContent = std::to_string(startTime) + ",auto"; |
| 395 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | PutFileContents(FPP_MEDIA_DIR + "/tmp/boot_delay", flagContent); |
| 396 | 3 | } | |
| 397 | } | ||
| 398 | } else { | ||
| 399 | // Ensure no boot delay flag file exists. No delay in docker. | ||
| 400 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | unlink((FPP_MEDIA_DIR + "/tmp/boot_delay").c_str()); |
| 401 | } | ||
| 402 | |||
| 403 | // Notify systemd that initialization is complete | ||
| 404 |
1/2✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
|
39 | sd_notify(0, "READY=1\nSTATUS=FPP initialization complete"); |
| 405 |
3/4✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 192 times.
|
229 | } else if (action == "postNetwork") { |
| 406 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | handleBootDelay(); |
| 407 | // turn off blinking cursor + clean up kiosk leftovers (quick, independent) | ||
| 408 |
3/6✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
|
111 | PutFileContents("/sys/class/graphics/fbcon/cursor_blink", "0"); |
| 409 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | cleanupChromiumFiles(); |
| 410 | |||
| 411 | // Audio setup and network bring-up no longer depend on each other (the | ||
| 412 | // flite IP announcement moved out to fpp-announce-ip.service), so run | ||
| 413 | // them concurrently. The network thread spends most of its time *waiting* | ||
| 414 | // (DHCP lease, NTP sync), yielding the CPU, while setupAudio does its | ||
| 415 | // CPU/IO work -- so they overlap well even on a single-core board and | ||
| 416 | // shorten postNetwork. | ||
| 417 | // | ||
| 418 | // Thread-safety: the only shared mutable state is /home/fpp/media/settings. | ||
| 419 | // setupAudio() is the SOLE writer; the network functions only read it. | ||
| 420 | // get/setRawSetting go through GetFileContents/PutFileContents, which take | ||
| 421 | // an advisory flock (LOCK_SH / LOCK_EX), so a read never observes a partial | ||
| 422 | // write. Keep the network path settings-read-only to preserve this. Each | ||
| 423 | // thread is wrapped so an exception can't escape and std::terminate the | ||
| 424 | // whole boot. | ||
| 425 | ✗ | std::thread audioThread([]() { | |
| 426 | try { | ||
| 427 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | setupAudio(); |
| 428 | // The PipeWire services ship disabled and are NOT started at | ||
| 429 | // sound.target -- starting them only now, after setupAudio has | ||
| 430 | // written/validated the config, means PipeWire reads the correct | ||
| 431 | // graph on its first (and only) start instead of starting empty | ||
| 432 | // at boot and needing a restart. Backgrounded so the audio thread | ||
| 433 | // doesn't block on the service bring-up. fpp-pipewire is pulled in | ||
| 434 | // by the other two's Requires=, but list it for clarity. | ||
| 435 |
2/4✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
|
74 | execbg("systemctl start fpp-pipewire.service fpp-wireplumber.service fpp-pipewire-pulse.service &"); |
| 436 | ✗ | } catch (const std::exception& e) { | |
| 437 | ✗ | printf("FPP - setupAudio failed: %s\n", e.what()); | |
| 438 | ✗ | } | |
| 439 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
74 | }); |
| 440 | ✗ | std::thread networkThread([]() { | |
| 441 | try { | ||
| 442 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | removeDummyInterface(); |
| 443 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | checkWLANInterface(); |
| 444 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | removeDummyInterface(); |
| 445 | // Wait for an actual IP, not just link: fppd starts right after | ||
| 446 | // this service and needs the address in place (socket binds, | ||
| 447 | // MultiSync), and the time-sync wait below may need the network | ||
| 448 | // too. The boot path may also recover a dead USB adapter. | ||
| 449 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | waitForInterfacesUp(100, true); |
| 450 | // A wedged USB adapter has queued a reboot. Everything below is | ||
| 451 | // setup for a boot that is about to end, and this service is on | ||
| 452 | // fppd's dependency chain -- overrunning its start timeout here | ||
| 453 | // is what fails fppd, so finish immediately instead. | ||
| 454 |
3/4✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 2 times.
|
37 | if (!usbWedgeRebootPending()) { |
| 455 | // Interfaces exist and are associated by here, which is what iw | ||
| 456 | // needs; doing it earlier would miss an adapter that enumerated late. | ||
| 457 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | disableWLANPowerManagement(); |
| 458 | // Time sync wait happens AFTER interfaces are up so NTP can sync | ||
| 459 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | handleTimeSyncWait(); |
| 460 |
2/4✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
|
35 | if (!FileExists("/etc/fpp/desktop")) { |
| 461 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | maybeEnableTethering(); |
| 462 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | detectNetworkModules(); |
| 463 | } | ||
| 464 | } | ||
| 465 | ✗ | } catch (const std::exception& e) { | |
| 466 | ✗ | printf("FPP - network setup failed: %s\n", e.what()); | |
| 467 | ✗ | } | |
| 468 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
74 | }); |
| 469 | // setupTimezone and swap setup depend on neither thread, so run them here | ||
| 470 | // -- concurrent with the network thread's DHCP/NTP wait and the audio | ||
| 471 | // thread -- instead of serially after the joins. setupTimezone only READS | ||
| 472 | // settings, which is flock-safe against setupAudio's writes. | ||
| 473 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | setupTimezone(); // this may not have worked in the init phase, try again |
| 474 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | startZRAMSwap(); |
| 475 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | startDiskSwap(); |
| 476 | // Fan/thermal drivers (e.g. pwm-fan) may be kernel modules that probe | ||
| 477 | // after the early "start" phase ran, so re-apply the trip settings here. | ||
| 478 | // Zones already snapshotted at "start" are not re-captured; one that | ||
| 479 | // only appeared now is still at its device tree values. | ||
| 480 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | applyThermalSettings(true); |
| 481 | |||
| 482 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | audioThread.join(); |
| 483 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | networkThread.join(); |
| 484 | |||
| 485 | // checkConfigMigrations doesn't need the network, but runs here anyway, | ||
| 486 | // right beside checkInstallPackages -- both are gated on the same | ||
| 487 | // markers, so keeping them together keeps that shared precondition | ||
| 488 | // visible in one place. | ||
| 489 | // | ||
| 490 | // /fppos_upgraded is touched by an OS reflash (upgradeOS-part2.sh) | ||
| 491 | // and /fpp_restored by a restore: www/backup.php after any JSON | ||
| 492 | // restore area, www/copystorage.php after a File Copy restore of | ||
| 493 | // Configuration, Plugins or EEPROM. A restore gets the packages and | ||
| 494 | // migrations, not the reflash's plugin handling. | ||
| 495 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | checkConfigMigrations(); |
| 496 | |||
| 497 | // Both of these must run after a join: | ||
| 498 | // - checkInstallPackages may apt-install user packages after an OS | ||
| 499 | // upgrade or a restore (see the marker note above), so | ||
| 500 | // it needs the network up (network thread joined). | ||
| 501 | // - setFileOwnership chowns /home/fpp/media, where setupAudio writes its | ||
| 502 | // PipeWire config as root, so it must follow the audio thread -- run it | ||
| 503 | // last so it also catches anything checkInstallPackages dropped there. | ||
| 504 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | checkInstallPackages(); |
| 505 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | setFileOwnership(); |
| 506 | // Notify systemd that post-network setup is complete | ||
| 507 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | sd_notify(0, "READY=1\nSTATUS=FPP post-network setup complete"); |
| 508 |
3/4✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 189 times.
|
229 | } else if (action == "bootPre") { |
| 509 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | int restart = getRawSettingInt("restartFlag", 0); |
| 510 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (restart) { |
| 511 | ✗ | printf("FPP - Clearing restart flags\n"); | |
| 512 | ✗ | setRawSetting("restartFlag", "0"); | |
| 513 | } | ||
| 514 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | migrateLegacyFppMode(); |
| 515 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | migrateRemoteCommands(); |
| 516 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | setupChannelOutputs(); |
| 517 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
6 | runScripts("preStart", true); |
| 518 |
2/4✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
|
189 | } else if (action == "bootPost") { |
| 519 | ✗ | std::this_thread::sleep_for(std::chrono::milliseconds(100)); | |
| 520 | ✗ | runScripts("postStart", false); | |
| 521 |
3/4✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 186 times.
|
189 | } else if (action == "runPreStartScripts") { |
| 522 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
6 | runScripts("preStart", true); |
| 523 |
2/4✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 186 times.
|
186 | } else if (action == "runPostStartScripts") { |
| 524 | ✗ | runScripts("postStart", false); | |
| 525 |
2/4✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 186 times.
|
186 | } else if (action == "runPreStopScripts") { |
| 526 | ✗ | runScripts("preStop", true); | |
| 527 |
2/4✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 186 times.
|
186 | } else if (action == "runPostStopScripts") { |
| 528 | ✗ | runScripts("postStop", false); | |
| 529 |
3/4✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 103 times.
|
186 | } else if (action == "setupAudio") { |
| 530 |
1/2✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
|
83 | setupAudio(); |
| 531 |
3/4✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 101 times.
|
103 | } else if (action == "announceIP") { |
| 532 | // Run from fpp-announce-ip.service, after fpp_postnetwork + PipeWire, so | ||
| 533 | // the flite synthesis doesn't slow the tail of postNetwork / fppd start. | ||
| 534 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | announceIPAddresses(); |
| 535 |
3/4✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 91 times.
|
101 | } else if (action == "configureBBB") { |
| 536 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | configureBBB(); |
| 537 |
2/4✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
|
91 | } else if (action == "applyThermal") { |
| 538 | ✗ | applyThermalSettings(); | |
| 539 |
2/4✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
|
91 | } else if (action == "resetThermal") { |
| 540 | ✗ | resetThermalSettings(); | |
| 541 |
3/4✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 88 times.
|
91 | } else if (action == "installKiosk") { |
| 542 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | installKiosk(); |
| 543 |
3/4✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 85 times.
|
88 | } else if (action == "setupPiRTC") { |
| 544 | // The UI's "reboot": 1 on DisablePiRTC prompts the user; don't reboot here. | ||
| 545 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | setupPiRTCConfig(false); |
| 546 |
3/4✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 84 times.
|
85 | } else if (action == "setupHDMICEC") { |
| 547 | // The UI's "reboot": 1 on DisableHDMICECInit prompts the user; don't reboot here. | ||
| 548 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | setupHDMICECConfig(false); |
| 549 |
3/4✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 80 times.
|
84 | } else if (action == "setupWifiAntenna") { |
| 550 | // The UI's "reboot": 1 on WifiAntenna prompts the user; don't reboot here. | ||
| 551 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | setupWifiAntennaConfig(false); |
| 552 |
3/4✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 78 times.
|
80 | } else if (action == "setup16KPageKernel") { |
| 553 | // The UI's "reboot": 1 on Pi16KPageKernel prompts the user; don't reboot here. | ||
| 554 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | setup16KPageKernel(false); |
| 555 |
3/4✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 37 times.
|
78 | } else if (action == "setupNetwork") { |
| 556 |
2/4✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
|
41 | PutFileContents(networkSetupMut, "1"); |
| 557 |
1/2✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
|
41 | setupNetwork(true); |
| 558 |
1/2✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
|
41 | waitForInterfacesUp(70); |
| 559 |
1/2✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
|
41 | detectNetworkModules(); |
| 560 |
1/2✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
|
41 | maybeEnableTethering(); |
| 561 | 41 | unlink(networkSetupMut.c_str()); | |
| 562 |
2/4✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
|
37 | } else if (action == "applyNTPFromDHCP") { |
| 563 | // The UseNTPFromDHCP setting changed. Two things follow it: the | ||
| 564 | // networkd files (UseNTP=no stops networkd asking the DHCP server for | ||
| 565 | // NTP servers at all, so the lease has none to offer) and chrony's | ||
| 566 | // sources in /run/chrony-dhcp, which the routable.d hook fills from the | ||
| 567 | // leases. setupNetwork() rewrites the files, and networkd reloads when | ||
| 568 | // one changed, renewing the lease with the new request list. Refresh | ||
| 569 | // chrony's sources now, and again once the renewed lease is likely in: | ||
| 570 | // a reload keeps the link routable, so the hook doesn't run by itself. | ||
| 571 | ✗ | if (!FileExists("/etc/fpp/desktop") && !getRawSettingInt("SkipNetworkReset", 0)) { | |
| 572 | ✗ | PutFileContents(networkSetupMut, "1"); | |
| 573 | ✗ | setupNetwork(false); | |
| 574 | ✗ | unlink(networkSetupMut.c_str()); | |
| 575 | } | ||
| 576 | ✗ | static const std::string hook = "/opt/fpp/etc/networkd-dispatcher/routable.d/chrony --sources-only"; | |
| 577 | ✗ | exec(hook); | |
| 578 | ✗ | sleep(10); | |
| 579 | ✗ | exec(hook); | |
| 580 |
3/4✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 31 times.
|
37 | } else if (action == "checkForTether") { |
| 581 |
3/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1 times.
|
6 | if (!FileExists(networkSetupMut)) { |
| 582 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | std::string a = execAndReturn("systemctl is-active fpp_postnetwork"); |
| 583 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | TrimWhiteSpace(a); |
| 584 |
3/6✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | if (a.starts_with("active") && argc >= 3) { |
| 585 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | std::string iface = argv[2]; |
| 586 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (iface.starts_with("wlan")) { |
| 587 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | waitForInterfacesUp(20); |
| 588 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | maybeEnableTethering(); |
| 589 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | detectNetworkModules(); |
| 590 | } | ||
| 591 | 5 | } | |
| 592 | 5 | } | |
| 593 |
3/4✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 25 times.
|
31 | } else if (action == "maybeRemoveTether") { |
| 594 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | int te = getRawSettingInt("EnableTethering", 0); |
| 595 |
6/8✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 1 times.
|
6 | if (!FileExists(networkSetupMut) && (te != 1)) { |
| 596 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
10 | std::string e = execAndReturn("systemctl is-enabled hostapd"); |
| 597 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | std::string a = execAndReturn("systemctl is-active hostapd"); |
| 598 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | TrimWhiteSpace(e); |
| 599 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | TrimWhiteSpace(a); |
| 600 |
5/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
|
5 | if (a.starts_with("active") || e.starts_with("enabled")) { |
| 601 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | std::string iface = argv[2]; |
| 602 |
11/18✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
4 | if (FindTetherWIFIAdapater() != iface && !iface.starts_with("usb") && !iface.starts_with("lo") && waitForInterfacesUp(10)) { |
| 603 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
2 | exec("rm -f /etc/systemd/network/10-" + FindTetherWIFIAdapater() + ".network"); |
| 604 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | exec("rm -f " + FPP_MEDIA_DIR + "/tmp/wifi-*.ascii"); |
| 605 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | exec("systemctl stop hostapd.service"); |
| 606 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | exec("systemctl disable hostapd.service"); |
| 607 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | exec("systemctl reload-or-restart systemd-networkd.service"); |
| 608 | } | ||
| 609 | 4 | } | |
| 610 | 5 | } | |
| 611 |
3/4✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 24 times.
|
25 | } else if (action == "detectNetworkModules") { |
| 612 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | detectNetworkModules(); |
| 613 |
3/4✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 9 times.
|
24 | } else if (action == "setupChannelOutputs") { |
| 614 | // The single steps below normally run inside start/bootPre; as actions | ||
| 615 | // of their own they can be run, and tested, one at a time | ||
| 616 | // (FPP_MEDIA_DIR points them at another media directory). | ||
| 617 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | setupChannelOutputs(); |
| 618 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | } else if (action == "checkConfigMigrations") { |
| 619 | ✗ | checkConfigMigrations(); | |
| 620 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | } else if (action == "detectCape") { |
| 621 | ✗ | DetectCape(); | |
| 622 |
3/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6 times.
|
9 | } else if (action == "setupTimezone") { |
| 623 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | setupTimezone(); |
| 624 |
3/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
|
6 | } else if (action == "checkHostName") { |
| 625 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | checkHostName(); |
| 626 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | } else if (action == "handleBootActions") { |
| 627 | ✗ | handleBootActions(); | |
| 628 |
3/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
2 | } else if (action == "reboot") { |
| 629 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | handleRebootActions(); |
| 630 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | } else if (action == "resizeRootFS") { |
| 631 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | resizeRootFS(); |
| 632 | } | ||
| 633 |
1/2✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
|
268 | printf("------------------------------\n"); |
| 634 | 268 | return 0; | |
| 635 | 268 | } | |
| 636 |