From 56bd3dc6a15f667b9de128eca9df8ac119706586 Mon Sep 17 00:00:00 2001 From: shihaam Date: Fri, 4 Nov 2022 23:01:15 +0500 Subject: [PATCH] commented init script --- buildfiles/auto_config.sh | 2 + buildfiles/setup-nextcloud.php | 759 --------------------------------- 2 files changed, 2 insertions(+), 759 deletions(-) delete mode 100644 buildfiles/setup-nextcloud.php diff --git a/buildfiles/auto_config.sh b/buildfiles/auto_config.sh index 2deefd0..702b01e 100644 --- a/buildfiles/auto_config.sh +++ b/buildfiles/auto_config.sh @@ -20,6 +20,8 @@ mkdir -pv /root/logs/nextcloud mkdir /tmp/nextcloudtemp chmod -R 777 /tmp/nextcloudtemp + +#Change netcloud dir ownership chown -R www-data:www-data /root/logs/nextcloud/ chown -R www-data:www-data /var/www/html/ diff --git a/buildfiles/setup-nextcloud.php b/buildfiles/setup-nextcloud.php deleted file mode 100644 index f6d5ff1..0000000 --- a/buildfiles/setup-nextcloud.php +++ /dev/null @@ -1,759 +0,0 @@ -. - * - */ - -/** - * Please copy this file into your webserver root and open it with a browser. The setup wizard checks the dependency, downloads the newest Nextcloud version, unpacks it and redirects to the Nextcloud first run wizard. - */ - -// Nextcloud version with possible values from https://download.nextcloud.com/server/releases/*.zip -define('NC_VERSION', 'latest'); - -// init -ob_start(); -error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); -ini_set('display_errors', 1); -@set_time_limit(0); - -/** - * Setup class with a few helper functions - */ -class Setup { - - private static $requirements = array( - array( - 'classes' => array( - 'ZipArchive' => 'zip', - 'DOMDocument' => 'dom', - 'XMLWriter' => 'XMLWriter' - ), - 'functions' => array( - 'xml_parser_create' => 'libxml', - 'mb_detect_encoding' => 'mb multibyte', - 'ctype_digit' => 'ctype', - 'json_encode' => 'JSON', - 'gd_info' => 'GD', - 'gzencode' => 'zlib', - 'iconv' => 'iconv', - 'simplexml_load_string' => 'SimpleXML', - 'hash' => 'HASH Message Digest Framework', - 'curl_init' => 'curl', - ), - 'defined' => array( - 'PDO::ATTR_DRIVER_NAME' => 'PDO' - ), - ) - ); - - - /** - * Checks if all the Nextcloud dependencies are installed - * @return string with error messages - */ - static public function checkDependencies() { - $error = ''; - $missingDependencies = array(); - - // do we have PHP 7.3.0 or newer? - if(version_compare(PHP_VERSION, '7.3.0', '<')) { - $error.='PHP 7.3.0 is required. Please ask your server administrator to update PHP to version 7.3.0 or higher.
'; - } - - // running oC on windows is unsupported since 8.1 - if(substr(PHP_OS, 0, 3) === "WIN") { - $error.='Nextcloud Server does not support Microsoft Windows.
'; - } - - foreach (self::$requirements[0]['classes'] as $class => $module) { - if (!class_exists($class)) { - $missingDependencies[] = array($module); - } - } - foreach (self::$requirements[0]['functions'] as $function => $module) { - if (!function_exists($function)) { - $missingDependencies[] = array($module); - } - } - foreach (self::$requirements[0]['defined'] as $defined => $module) { - if (!defined($defined)) { - $missingDependencies[] = array($module); - } - } - - if(!empty($missingDependencies)) { - $error .= 'The following PHP modules are required to use Nextcloud:
'; - } - foreach($missingDependencies as $missingDependency) { - $error .= '
  • '.$missingDependency[0].'
  • '; - } - if(!empty($missingDependencies)) { - $error .= '

    Please contact your server administrator to install the missing modules.

    '; - } - - // do we have write permission? - if(!is_writable('.')) { - $error.='Can\'t write to the current directory. Please fix this by giving the webserver user write access to the directory.
    '; - } - - return($error); - } - - - /** - * Check the cURL version - * @return bool status of CURLOPT_CERTINFO implementation - */ - static public function isCertInfoAvailable() { - $curlDetails = curl_version(); - return version_compare($curlDetails['version'], '7.19.1') != -1; - } - - /** - * Performs the Nextcloud install. - * @return string with error messages - */ - static public function install() { - $error = ''; - $directory = trim($_GET['directory']); - - // Test if folder already exists - if(file_exists('./'.$directory.'/status.php')) { - return 'The selected folder seems to already contain a Nextcloud installation. - You cannot use this script to update existing installations.'; - } - - // downloading latest release - if (!file_exists('nc.zip')) { - $error .= Setup::getFile('https://download.nextcloud.com/server/releases/'.NC_VERSION.'.zip','nc.zip'); - } - - // unpacking into nextcloud folder - $zip = new ZipArchive; - $res = $zip->open('nc.zip'); - if ($res==true) { - // Extract it to the tmp dir - $nextcloud_tmp_dir = 'tmp-nextcloud'.time(); - $zip->extractTo($nextcloud_tmp_dir); - $zip->close(); - - // Move it to the folder - if ($_GET['directory'] === '.') { - foreach (array_diff(scandir($nextcloud_tmp_dir.'/nextcloud'), array('..', '.')) as $item) { - rename($nextcloud_tmp_dir.'/nextcloud/'.$item, './'.$item); - } - rmdir($nextcloud_tmp_dir.'/nextcloud'); - } else { - rename($nextcloud_tmp_dir.'/nextcloud', './'.$directory); - } - // Delete the tmp folder - rmdir($nextcloud_tmp_dir); - } else { - $error.='unzip of nextcloud source file failed.
    '; - } - - // deleting zip file - $result=@unlink('nc.zip'); - if($result==false) $error.='deleting of nc.zip failed.
    '; - return($error); - } - - - /** - * Downloads a file and stores it in the local filesystem - * @param string $url - * @param string$path - * @return string with error messages - */ - static public function getFile($url,$path) { - $error=''; - - $fp = fopen ($path, 'w+'); - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_TIMEOUT, 0); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); - if (Setup::isCertInfoAvailable()){ - curl_setopt($ch, CURLOPT_CERTINFO, TRUE); - } - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); - $data=curl_exec($ch); - $curlError=curl_error($ch); - curl_close($ch); - fclose($fp); - - if($data==false){ - $error.='download of Nextcloud source file failed.
    '.$curlError; - } - return($error.$curlError); - - } - - - /** - * Shows the html header of the setup page - */ - static public function showHeader() { - echo(' - - - - Nextcloud Setup - - - - - - - - - - '); - } - - - /** - * Shows the html footer of the setup page - */ - static public function showFooter() { - echo(' - - - - '); - } - - - /** - * Shows the html content part of the setup page - * @param string $title - * @param string $content - * @param string $nextpage - */ - static public function showContent($title, $content, $nextpage=''){ - echo(' - -
    -
    -

    -

    '.$title.'


    -
    -

    '.$content.'

    - - '); - - if($nextpage === 2) { - echo ('

    Enter a single "." to install in the current directory, or enter a subdirectory to install to:

    - '); - } - if($nextpage === 3) { - echo (''); - } - - if($nextpage<>'') echo(''); - - echo(' -
    -
    -
    -
    - '); - } - - /** - * JS function to check if user deleted this script - * N.B. We can't reload the page to check this with PHP: - * once script is deleted we end up with 404 - */ - static public function showJsValidation(){ - echo ' - - '; - } - - - /** - * Shows the welcome screen of the setup wizard - */ - static public function showWelcome() { - $txt='Welcome to the Setup Wizard for
    Nextcloud!

    This wizard will:
    1. Check the server dependencies
    2. Download Nextcloud
    3. Install Nextcloud in a few simple steps'; - Setup::showContent('Setup Wizard',$txt,1); - } - - - /** - * Shows the check dependencies screen - */ - static public function showCheckDependencies() { - $error=Setup::checkDependencies(); - if($error=='') { - $txt='All Nextcloud dependencies found'; - Setup::showContent('Dependency check',$txt,2); - }else{ - $txt='Dependencies not found.
    '.$error; - Setup::showContent('Dependency check',$txt); - } - } - - - /** - * Shows the install screen - */ - static public function showInstall() { - $error=Setup::install(); - - if($error=='') { - $txt='Nextcloud is now installed'; - Setup::showContent('Success',$txt,3); - }else{ - $txt='Nextcloud is NOT installed
    '.$error; - Setup::showContent('Error',$txt); - } - } - - /** - * Shows the redirect screen - */ - static public function showRedirect() { - // delete own file - @unlink(__FILE__); - clearstatcache(); - if (file_exists(__FILE__)){ - Setup::showJsValidation(); - Setup::showContent( - 'Warning', - 'Failed to remove installer script. Please remove ' . __FILE__ . ' manually', - 3 - ); - } else { - // redirect to Nextcloud - header("Location: " . $_GET['directory']); - } - } - -} - - -// read the step get variable -$step = isset($_GET['step']) ? $_GET['step'] : 0; - -// show the header -Setup::showHeader(); - -// show the right step -if ($step==0) Setup::showWelcome(); -elseif ($step==1) Setup::showCheckDependencies(); -elseif ($step==2) Setup::showInstall(); -elseif ($step==3) Setup::showRedirect(); -else echo('Internal error. Please try again.'); - -// show the footer -Setup::showFooter();