Remove obsolete code, delete shutdown command upon uninstall

This commit is contained in:
Jose
2019-11-01 17:09:30 -04:00
parent d385820a09
commit 8485d98d9b
4 changed files with 28 additions and 48 deletions
+1
View File
@@ -3,6 +3,7 @@
====================== ======================
Version Description Version Description
1.0.4......Remove obsolete code, delete shutdown command upon uninstall.
1.0.3......Do not delete base releases with containers child. 1.0.3......Do not delete base releases with containers child.
1.0.2......Code and regex improvements. 1.0.2......Code and regex improvements.
1.0.1......Update paths and minor changes. 1.0.1......Update paths and minor changes.
+3 -27
View File
@@ -328,32 +328,8 @@ postinit_cmd()
if ! grep -qw ${CWDIR}/${SCRIPTNAME} ${CONFIG}; then if ! grep -qw ${CWDIR}/${SCRIPTNAME} ${CONFIG}; then
touch ${CWDIR}/postinit || error_notify "Error: A problem has occurred while creating the postinit file." touch ${CWDIR}/postinit || error_notify "Error: A problem has occurred while creating the postinit file."
chmod +x ${CWDIR}/postinit chmod +x ${CWDIR}/postinit
if [ ! "${PRDVERSION}" -ge "112" ]; then if [ "${PRDVERSION}" -ge "110" ]; then
# Generate php script for previous product versions. # Generate php script for start/stop commands.
cat << EOF > ${CWDIR}/postinit
<?php
require_once("config.inc");
require_once("functions.inc");
\$cmd = dirname(__FILE__)."/${SCRIPTNAME}";
\$i =0;
if ( is_array(\$config['rc']['postinit'] ) && is_array( \$config['rc']['postinit']['cmd'] ) ) {
for (\$i; \$i < count(\$config['rc']['postinit']['cmd']);) {
if (preg_match('/${SCRIPTNAME}/', \$config['rc']['postinit']['cmd'][\$i])) break; ++\$i; }
}
\$config['rc']['postinit']['cmd'][\$i] = \$config['cmd']."\$cmd";
write_config();
\$i =0;
if ( is_array(\$config['rc']['shutdown'] ) && is_array( \$config['rc']['shutdown']['cmd'] ) ) {
for (\$i; \$i < count(\$config['rc']['shutdown']['cmd']);) {
if (preg_match('/${SCRIPTNAME}/', \$config['rc']['shutdown']['cmd'][\$i])) break; ++\$i; }
}
\$config['rc']['shutdown']['cmd'][\$i] = \$config['cmd']."\$cmd";
write_config();
?>
EOF
else
# Generate php script for later product versions.
cat << EOF > ${CWDIR}/postinit cat << EOF > ${CWDIR}/postinit
<?php <?php
require_once("config.inc"); require_once("config.inc");
@@ -383,7 +359,7 @@ if(false === array_search_ex(\$cmd2,\$rc,'cmd2')):
\$rc_param['uuid'] = uuid(); \$rc_param['uuid'] = uuid();
\$rc_param['name'] = \$name; \$rc_param['name'] = \$name;
\$rc_param['value'] = \$cmd2; \$rc_param['value'] = \$cmd2;
\$rc_param['comment2'] = \$comment2; \$rc_param['comment'] = \$comment2;
\$rc_param['typeid'] = '3'; \$rc_param['typeid'] = '3';
\$rc_param['enable'] = true; \$rc_param['enable'] = true;
\$rc[] = \$rc_param; \$rc[] = \$rc_param;
+23 -20
View File
@@ -92,36 +92,39 @@ if ($_POST) {
if (is_link("/usr/local/share/{$prdname}")) mwexec("rm /usr/local/share/{$prdname}", true); if (is_link("/usr/local/share/{$prdname}")) mwexec("rm /usr/local/share/{$prdname}", true);
if (is_link("/var/cache/pkg")) mwexec("rm /var/cache/pkg", true); if (is_link("/var/cache/pkg")) mwexec("rm /var/cache/pkg", true);
if (is_link("/var/db/pkg")) mwexec("rm /var/db/pkg && mkdir /var/db/pkg", true); if (is_link("/var/db/pkg")) mwexec("rm /var/db/pkg && mkdir /var/db/pkg", true);
// Remove postinit cmd in legacy product versions.
$return_val = mwexec("/bin/cat /etc/prd.version | cut -d'.' -f1 | /usr/bin/grep '10'", true);
if ($return_val == 0) {
if (is_array($config['rc']['postinit']) && is_array($config['rc']['postinit']['cmd'])) {
for ($i = 0; $i < count($config['rc']['postinit']['cmd']);) {
if (preg_match('/bastille-init/', $config['rc']['postinit']['cmd'][$i])) { unset($config['rc']['postinit']['cmd'][$i]); }
++$i;
}
}
write_config();
}
// Remove postinit cmd in later product versions. // Remove start postinit cmd in later product versions.
if (is_array($config['rc']) && is_array($config['rc']['param'])) { if (is_array($config['rc']) && is_array($config['rc']['param'])) {
$postinit_cmd = "{$rootfolder}/bastille-init"; $postinit_cmd = "{$rootfolder}/bastille-init";
$value = $postinit_cmd; $value = $postinit_cmd;
$sphere_array = &$config['rc']['param']; $sphere_array = &$config['rc']['param'];
$updateconfigfile = false; $updateconfigfile = false;
if (false !== ($index = array_search_ex($value, $sphere_array, 'value'))) { if (false !== ($index = array_search_ex($value, $sphere_array, 'value'))) {
unset($sphere_array[$index]); unset($sphere_array[$index]);
$updateconfigfile = true; $updateconfigfile = true;
}
if ($updateconfigfile) {
write_config();
$updateconfigfile = false;
}
} }
if ($updateconfigfile) { // Remove stop postinit cmd in later product versions.
write_config(); if (is_array($config['rc']) && is_array($config['rc']['param'])) {
$shutdown_cmd = "{$rootfolder}/bastille-init -p";
$value = $shutdown_cmd;
$sphere_array = &$config['rc']['param'];
$updateconfigfile = false; $updateconfigfile = false;
if (false !== ($index = array_search_ex($value, $sphere_array, 'value'))) {
unset($sphere_array[$index]);
$updateconfigfile = true;
}
if ($updateconfigfile) {
write_config();
$updateconfigfile = false;
}
} }
header("Location:index.php");
} }
header("Location:index.php");
}
if (isset($_POST['save']) && $_POST['save']) { if (isset($_POST['save']) && $_POST['save']) {
// Ensure to have NO whitespace & trailing slash. // Ensure to have NO whitespace & trailing slash.
+1 -1
View File
@@ -1 +1 @@
1.0.3 1.0.4