lcd4l: apply calls of exec_initscript() with "systemctl" as 3rd argument

Is required for image with system

NOTE: CLCD4l::lcd4linux(int run) is adjusted
but not really used at the moment
This commit is contained in:
2021-06-30 18:28:33 +02:00
parent de4a6ade64
commit 9a68009b96
2 changed files with 51 additions and 38 deletions

View File

@@ -161,7 +161,7 @@ void CLCD4l::StartLCD4l()
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] is running\033[0m\n", __func__, __LINE__, thrLCD4l);
}
if (g_settings.lcd4l_support)
exec_initscript("lcd4linux", "start");
exec_initscript("lcd4linux", "start", "systemctl");
}
void CLCD4l::StopLCD4l()
@@ -178,7 +178,7 @@ void CLCD4l::StopLCD4l()
thrLCD4l = NULL;
dprintf(DEBUG_NORMAL, "\033[32m[CLCD4l] [%s - %d] thread [%p] terminated\033[0m\n", __func__, __LINE__, thrLCD4l);
}
exec_initscript("lcd4linux", "stop");
exec_initscript("lcd4linux", "stop", "systemctl");
}
void CLCD4l::SwitchLCD4l()
@@ -298,7 +298,6 @@ void CLCD4l::Init()
void *CLCD4l::LCD4lProc(void *arg)
{
CLCD4l *PLCD4l = static_cast<CLCD4l *>(arg);
PLCD4l->Init();
sleep(5); //please wait !
@@ -341,11 +340,6 @@ void *CLCD4l::LCD4lProc(void *arg)
PLCD4l->WriteFile(FLAG_LCD4LINUX);
FirstRun = false;
}
if (!g_settings.lcd4l_support) //off
lcd4linux(false);
else
lcd4linux(true);
}
return 0;
}
@@ -543,6 +537,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun)
m_Tuner = Tuner;
}
}
/* ----------------------------------------------------------------- */
int Volume = g_settings.current_volume;
@@ -872,7 +867,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun)
WriteFile(LAYOUT, Layout);
m_Layout = Layout;
if (!firstRun)
exec_initscript("lcd4linux", "reload");
exec_initscript("lcd4linux", "restart", "systemctl");
}
}
@@ -1264,17 +1259,22 @@ std::string CLCD4l::hexStrA2A(unsigned char data)
return std::string(hexstr);
}
void CLCD4l::lcd4linux(bool run)
void CLCD4l::lcd4linux(int run)
{
const char *buf = "lcd4linux";
const char *lcd4lbin = "lcd4linux";
const char *conf = "/etc/lcd4linux.conf";
std::string lcd4l_bin = find_executable(buf);
const std::string systemd_cmd = "systemctl";
std::string lcd4lbin_path = find_executable(lcd4lbin);
bool isPNG;
chmod(conf,0x600);
chown(conf,0,0);
if (run == true)
int lcd4_pid = getpidof(lcd4lbin);
if (run == START_LCD4L)
{
if (lcd4_pid == 0)
{
switch (g_settings.lcd4l_display_type)
{
@@ -1290,22 +1290,28 @@ void CLCD4l::lcd4linux(bool run)
if (isPNG)
{
if (my_system(3, lcd4l_bin.c_str(), "-o", PNGFILE) != 0)
printf("[CLCD4l] %s: executing '%s -o %s' failed\n", __FUNCTION__, lcd4l_bin.c_str(), PNGFILE);
} else {
if (my_system(1, lcd4l_bin.c_str()) != 0)
printf("[CLCD4l] %s: executing '%s' failed\n", __FUNCTION__, lcd4l_bin.c_str());
if (my_system(3, lcd4lbin_path.c_str(), "-o", PNGFILE) != 0)
dprintf(DEBUG_NORMAL,"\033[33m[CLCD4l] [%s - %d] executing '%s -o %s' failed \033[0m\n", __func__, __LINE__, lcd4lbin, PNGFILE);
}
else
{
if (exec_initscript(lcd4lbin, "start", systemd_cmd) != 0)
dprintf(DEBUG_NORMAL,"\033[33m[CLCD4l] [%s - %d] %s start failed \033[0m\n", __func__, __LINE__, lcd4lbin);
}
sleep(2);
}
else
}
else if (run == RELOAD_LCD4L)
{
if (file_exists(PIDFILE))
{
if (my_system(3, "killall", "-9", buf) != 0)
printf("[CLCD4l] %s: terminating '%s' failed\n", __FUNCTION__, buf);
if (exec_initscript(lcd4lbin, "reload", systemd_cmd) != 0)
dprintf(DEBUG_NORMAL,"\033[33m[CLCD4l] [%s - %d] %s reload failed \033[0m\n", __func__, __LINE__, lcd4lbin);
}
else
dprintf(DEBUG_NORMAL,"\033[33m[CLCD4l] [%s - %d] %s is not running \033[0m\n", __func__, __LINE__,lcd4l_bin.c_str());
{
if (lcd4_pid)
{
if (exec_initscript(lcd4lbin, "stop", systemd_cmd) != 0)
dprintf(DEBUG_NORMAL,"\033[33m[CLCD4l] [%s - %d] %s stop failed \033[0m\n", __func__, __LINE__, lcd4lbin);
}
}
}

View File

@@ -67,7 +67,14 @@ class CLCD4l
int GetMaxBrightness();
void ResetParseID() { m_ParseID = 0; }
static void lcd4linux(bool run);
static void lcd4linux(int run);
enum
{
STOP_LCD4L = 0,
START_LCD4L = 1,
RELOAD_LCD4L = 2
};
private:
std::thread *thrLCD4l;
static void *LCD4lProc(void *arg);