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

View File

@@ -3,6 +3,7 @@
======================
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.2......Code and regex improvements.
1.0.1......Update paths and minor changes.

View File

@@ -328,32 +328,8 @@ postinit_cmd()
if ! grep -qw ${CWDIR}/${SCRIPTNAME} ${CONFIG}; then
touch ${CWDIR}/postinit || error_notify "Error: A problem has occurred while creating the postinit file."
chmod +x ${CWDIR}/postinit
if [ ! "${PRDVERSION}" -ge "112" ]; then
# Generate php script for previous product versions.
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.
if [ "${PRDVERSION}" -ge "110" ]; then
# Generate php script for start/stop commands.
cat << EOF > ${CWDIR}/postinit
<?php
require_once("config.inc");
@@ -383,7 +359,7 @@ if(false === array_search_ex(\$cmd2,\$rc,'cmd2')):
\$rc_param['uuid'] = uuid();
\$rc_param['name'] = \$name;
\$rc_param['value'] = \$cmd2;
\$rc_param['comment2'] = \$comment2;
\$rc_param['comment'] = \$comment2;
\$rc_param['typeid'] = '3';
\$rc_param['enable'] = true;
\$rc[] = \$rc_param;

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("/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);
// 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'])) {
$postinit_cmd = "{$rootfolder}/bastille-init";
$value = $postinit_cmd;
$sphere_array = &$config['rc']['param'];
$updateconfigfile = false;
if (false !== ($index = array_search_ex($value, $sphere_array, 'value'))) {
unset($sphere_array[$index]);
$updateconfigfile = true;
if (false !== ($index = array_search_ex($value, $sphere_array, 'value'))) {
unset($sphere_array[$index]);
$updateconfigfile = true;
}
if ($updateconfigfile) {
write_config();
$updateconfigfile = false;
}
}
if ($updateconfigfile) {
write_config();
// Remove stop postinit cmd in later product versions.
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;
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']) {
// Ensure to have NO whitespace & trailing slash.

View File

@@ -1 +1 @@
1.0.3
1.0.4