function install() { $unix = new unix(); $DISTRICODE = $unix->LINUX_CODE_NAME(); $arch = $unix->LINUX_ARCHITECTURE(); $VERS = $unix->LINUX_VERS(); $dpkg = $unix->find_program("dpkg"); echo "DISTRICODE:{$DISTRICODE} \n"; if (!python_verify_modules("MySQLdb")) { $unix->DEBIAN_INSTALL_PACKAGE("python-mysqldb"); } if (!python_verify_modules("ldap")) { echo "Installing python-ldap\n"; if ($DISTRICODE == "DEBIAN") { if ($arch == 64) { if ($VERS[0] == 6) { if (is_file("/usr/share/artica-postfix/bin/install/postfix/python-6-ldap-amd64.deb")) { shell_exec("{$dpkg} -i --force-all /usr/share/artica-postfix/bin/install/postfix/python-6-ldap-amd64.deb"); } } if ($VERS[0] == 7) { if (is_file("/usr/share/artica-postfix/bin/install/postfix/python-7-ldap-amd64.deb")) { shell_exec("{$dpkg} -i --force-all /usr/share/artica-postfix/bin/install/postfix/python-7-ldap-amd64.deb"); } } } } } if (!python_verify_modules("ldap")) { $unix->DEBIAN_INSTALL_PACKAGE("python-ldap"); } if (!python_verify_modules("ldap")) { echo "Warning, ldap/python-ldap not installed...\n"; return; } if (!python_verify_modules("MySQLdb")) { echo "Warning, MySQLdb/python-mysqldb not installed...\n"; return; } echo "MySQLdb / python-mysqldb OK\n"; echo "LDAP / python-ldap OK\n"; $tmpdir = $unix->TEMP_DIR() . "/iredmail"; $tar = $unix->find_program("tar"); $rm = $unix->find_program("rm"); if (!is_file("/usr/share/artica-postfix/bin/install/postfix/iredapd.tar.gz")) { return; } @mkdir($tmpdir, 0755, true); shell_exec("{$tar} xf /usr/share/artica-postfix/bin/install/postfix/iredapd.tar.gz -C /"); if (!is_file("/opt/iRedAPD/iredapd.py")) { return; } @chmod("/opt/iRedAPD/iredapd.py", 0755); }
function install_video_cache($aspid = false) { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; if ($aspid) { $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n"; } return; } } @file_put_contents($pidfile, getmypid()); $modules["setuptools"] = true; $modules["iniparse"] = true; $modules["netifaces"] = true; $modules["cloghandler"] = true; $unix = new unix(); $python = $unix->find_program("python"); CHECK_DATABASE(); build_progress("Checking modules", 15); while (list($modulename, $line) = each($modules)) { build_progress("Checking modules {$modulename}", 20); if (!python_verify_modules($modulename)) { if (!install_module($modulename)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] {$modulename} failed\n"; } build_progress("Installing module {$modulename} failed", 110); return false; } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] {$modulename} INSTALLED\n"; } } } else { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] {$modulename}\n"; } } } $files = videocache_files(); $INSTALLED = true; while (list($modulename, $filepath) = each($files)) { if (!is_file($filepath)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] " . basename($filepath) . " no such file\n"; } $INSTALLED = false; break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [OK] " . basename($filepath) . " \n"; } } if (!$INSTALLED) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Installing VideoCache\n"; } if (!install_video_cache_python()) { build_progress("Installing videocache package failed", 110); return false; } $files = videocache_files(); while (list($modulename, $filepath) = each($files)) { if (!is_file($filepath)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} [!!] " . basename($filepath) . " no such file\n"; } return false; } } } $chattr = $unix->find_program("chattr"); shell_exec("{$chattr} +i -R /usr/share/videocache"); $tables["video_files"] = true; $tables["video_queue"] = true; $tables["youtube_cpns"] = true; $tablesz = true; build_progress("Installing Tables", 40); while (list($tablename, $line) = each($tables)) { if (!TABLE_EXISTS($tablename, "videocache")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} missing table {$tablename}\n"; } $tablesz = false; } } if (!$tablesz) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} upgrading videocache\n"; } shell_exec("{$python} /usr/share/videocache/vc-update >/dev/null 2>&1"); reset($tables); $GLOBALS["VIDEOCACHE_TABLES"] = array(); $tablesz = true; while (list($tablename, $line) = each($tables)) { if (!TABLE_EXISTS($tablename, "videocache")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} missing table {$tablename}\n"; } $tablesz = false; break; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} `{$tablename}` OK\n"; } } } if (!$tablesz) { build_progress("Installing Tables failed", 110); return false; } build_progress("Installing Tables success", 45); return true; // /artica-postfix/bin/install/squid/videocache.tar.gz }