use find_executable() to find scripts

Origin commit data
------------------
Commit: 05a3384959
Author: vanhofen <vanhofen@gmx.de>
Date: 2020-12-06 (Sun, 06 Dec 2020)

Origin message was:
------------------
- use find_executable() to find scripts
This commit is contained in:
vanhofen
2020-12-06 16:38:07 +01:00
parent 4840133e3f
commit 5e3d587ff9
2 changed files with 11 additions and 10 deletions

View File

@@ -141,10 +141,10 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SETTINGS_BACKUP)); CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SETTINGS_BACKUP));
hintBox->paint(); hintBox->paint();
const char backup_sh[] = TARGET_PREFIX "/bin/backup.sh"; std::string backup_sh = find_executable("backup.sh");
std::string fname = "settings_" + getBackupSuffix(); // file ending is set by backup script; std::string fname = "settings_" + getBackupSuffix(); // file ending is set by backup script;
dprintf(DEBUG_NORMAL, "[CSettingsManager]\t[%s - %d] executing [%s %s]\n", __func__, __LINE__, backup_sh, g_settings.backup_dir.c_str()); dprintf(DEBUG_NORMAL, "[CSettingsManager]\t[%s - %d] executing [%s %s]\n", __func__, __LINE__, backup_sh.c_str(), g_settings.backup_dir.c_str());
my_system(3, backup_sh, g_settings.backup_dir.c_str(), fname.c_str()); my_system(3, backup_sh.c_str(), g_settings.backup_dir.c_str(), fname.c_str());
hintBox->hide(); hintBox->hide();
delete hintBox; delete hintBox;
@@ -165,10 +165,10 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo); int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMsgBox::mbrNo, CMsgBox::mbYes | CMsgBox::mbNo);
if(result == CMsgBox::mbrYes) if(result == CMsgBox::mbrYes)
{ {
const char restore_sh[] = TARGET_PREFIX "/bin/restore.sh"; std::string restore_sh = find_executable("restore.sh");
std::string restore_file = fileBrowser.getSelectedFile()->Name; std::string restore_file = fileBrowser.getSelectedFile()->Name;
dprintf(DEBUG_NORMAL, "[CSettingsManager]\t[%s - %d] executing [%s %s]\n", __func__, __LINE__, restore_sh, restore_file.c_str()); dprintf(DEBUG_NORMAL, "[CSettingsManager]\t[%s - %d] executing [%s %s]\n", __func__, __LINE__, restore_sh.c_str(), restore_file.c_str());
my_system(2, restore_sh, restore_file.c_str()); my_system(2, restore_sh.c_str(), restore_file.c_str());
} }
} }
return res; return res;

View File

@@ -653,7 +653,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
ofgwrite will copy this tarball to new rootfs. ofgwrite will copy this tarball to new rootfs.
It's untared at first start of new image. It's untared at first start of new image.
*/ */
my_system(3, TARGET_PREFIX "/bin/backup.sh", "/tmp", "backup_flash"); // file ending is set by backup script; std::string backup_sh = find_executable("backup.sh");
my_system(3, backup_sh.c_str(), "/tmp", "backup_flash"); // file ending is set by backup script;
hintBox.hide(); hintBox.hide();
} }
@@ -765,10 +766,10 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
} }
else // not image, install else // not image, install
{ {
const char install_sh[] = TARGET_PREFIX "/bin/install.sh"; std::string install_sh = find_executable("install.sh");
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s\n",install_sh, g_settings.update_dir.c_str(), filename.c_str() ); dprintf(DEBUG_NORMAL, "[update] calling %s %s %s\n", install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str() );
#ifndef DRYRUN #ifndef DRYRUN
my_system(3, install_sh, g_settings.update_dir.c_str(), filename.c_str()); my_system(3, install_sh.c_str(), g_settings.update_dir.c_str(), filename.c_str());
#endif #endif
showGlobalStatus(100); showGlobalStatus(100);
ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_READY); ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_READY);