diff --git a/README.md b/README.md index 29609dfd..fb857764 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ Who is the target group for Easy-WI? ------------------------ No matter if you are a commercial entity that is providing hosting solutions, are sponsoring (game)server daemons, organize a LAN party, need to manage clan server, or are a private individual, Easy-WI is meant for everybody. +Where can I find the installer and other scripts? +------------------------ +* [Installer](https://github.com/easy-wi/installer/) +* [Optional Server Side Scripts](https://github.com/easy-wi/server/) +* [External PHP Scripst](https://github.com/easy-wi/external/) + Which functions and modules are available? ------------------------ diff --git a/external/api_config.php b/external/api_config.php deleted file mode 100644 index 1339ed48..00000000 --- a/external/api_config.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * This file is part of Easy-WI. - * - * Easy-WI is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Easy-WI is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Easy-WI. If not, see . - * - * Diese Datei ist Teil von Easy-WI. - * - * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen - * der GNU General Public License, wie von der Free Software Foundation, - * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren - * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. - * - * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber - * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite - * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. - * Siehe die GNU General Public License fuer weitere Details. - * - * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem - * Programm erhalten haben. Wenn nicht, siehe . - */ - -// The database access -$config['dbHost']='localhost'; -$config['dbName']='database'; -$config['tblPrefix']='teklab'; -$config['dbUser']='databaseUser'; -$config['dbPwd']='securePassword'; -$config['sourceSystem']='securePassword'; - -// Access to the file -$config['passwordToken']='myPasswordToken'; -$config['allowedIPs']=array('1.1.1.1','1.1.1.2'); - -// Type of System allowed are: -// webspell,teklab,whmcs -$config['sourceType']='webspell'; \ No newline at end of file diff --git a/external/api_users.php b/external/api_users.php deleted file mode 100644 index d279c2eb..00000000 --- a/external/api_users.php +++ /dev/null @@ -1,493 +0,0 @@ - - * - * This file is part of Easy-WI. - * - * Easy-WI is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Easy-WI is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Easy-WI. If not, see . - * - * Diese Datei ist Teil von Easy-WI. - * - * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen - * der GNU General Public License, wie von der Free Software Foundation, - * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren - * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. - * - * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber - * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite - * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. - * Siehe die GNU General Public License fuer weitere Details. - * - * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem - * Programm erhalten haben. Wenn nicht, siehe . - */ - -require_once 'api_config.php'; - -// Initial parameters -$error=array(); - -// There is no need to check every user every time -// Start looking only for new IDs -$lastID=(isset($_GET['lastID']) and is_numeric($_GET['lastID'])) ? (int)$_GET['lastID'] : 0; - -// this requires that a column exists which is updated every time the account gets an update: -// ALTER TABLE `yourUserTable` ADD COLUMN `updatetime` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP -// This might lead to false positives if data like the login time is stored in that table. -// The more accurate way would be to fill/update the column only in wanted cases -// convert to string and back to date so proper format is ensured -$updateTime=date('Y-m-d H:i:s',strtotime((isset($_GET['updateTime']) and @strtotime($_GET['updateTime'])) ? $_GET['updateTime'] : '0000-00-00 00:00:00')); - -// Processing all users at once can lead to memory issues if system has small recources or large database large. -$chunkSize=(isset($_GET['chunkSize']) and is_numeric($_GET['chunkSize'])) ? (int)$_GET['chunkSize'] : 10; - -// To be able to properly get data in chunks the starting point needs to be defined. -$start=(isset($_GET['start']) and is_numeric($_GET['start'])) ? (int)$_GET['start'] : 0; - -// Check if the IP is white listed -if(isset($_SERVER['REMOTE_ADDR']) and in_array($_SERVER['REMOTE_ADDR'],$config['allowedIPs'])) { - $config['externalIP']=(string)$_SERVER['REMOTE_ADDR']; -} else { - $error[]='Script called locally or IP is not white listed.'; -} - -// Check if access token was send and is correct -if (!isset($_GET['passwordToken'])) { - $error[]='No password token has been send.'; -} else if ($_GET['passwordToken']!=$config['passwordToken']) { - $error[]='Bad password token has been send.'; -} - -$list = (in_array($_GET['list'], array('user','substitutes','gameserver','voiceserver','voicemaster','rootserver'))) ? (string)$_GET['list'] : 'user'; - -// Send header data -header("Content-type: application/json; charset=UTF-8"); - -// If there was an error send error and stop script -if (count($error)>0) { - echo json_encode(array('error' => $error)); - -// Else check for new users -} else { - - // Establish database connection - try { - $pdo=new PDO("mysql:host=".$config['dbHost'].";dbname=".$config['dbName'],$config['dbUser'],$config['dbPwd'],array(PDO::MYSQL_ATTR_INIT_COMMAND=>"SET NAMES utf8")); - $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); - - // Define default values so we always have a proper return - $total = 0; - $json = array(); - - // User export - if ($list == 'user') { - // This query fetches the actual data. - // The Query needs to be altered to your database. This is just an example! - // specify the needed columns to reduce database load. - // webspell - if ($config['sourceType'] == 'webspell') { - - $lastID = str_replace($config['sourceType'] . ':', '', $lastID); - - // Get amount of users that are new or received an update - // The Query needs to be altered to your database. This is just an example! - $sql="SELECT COUNT(`userID`) AS `amount` FROM `{$config['tblPrefix']}_user` - WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND `banned` IS NULL"; - $query=$pdo->prepare($sql); - $query->execute(array($lastID, $updateTime)); - $total=$query->fetchColumn(); - - $sql = "SELECT * FROM `{$config['tblPrefix']}_usertable` - WHERE (`userID`>? OR `updatetime`>?) AND `activated`=1 AND (`banned` IS NULL OR `banned`='') - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(array($lastID, $updateTime)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - // Easy-Wi stores the salutation with numbers - if (isset($row['salutation']) and $row['salutation'] == 'mr') { - $salutation = 1; - } else if (isset($row['salutation']) and $row['salutation'] == 'ms') { - $salutation = 2; - } else { - $salutation = null; - } - // the keys needs to be adjusted to your table layout and query! - $json[]=array( - 'externalID' => $config['sourceType'] . ':' . $row['userID'], - 'salutation' => $salutation, - 'email' => $row['email'], - 'loginName' => $row['username'], - 'firstName' => $row['firstname'], - 'lastName' => $row['lastname'], - 'birthday' => $row['birthday'], - 'country' => $row['country'], - 'phone' => $row['tel'], - 'fax' => $row['fax'], - 'handy' => $row['mobile'], - 'city' => $row['town'], - 'cityn' => $row['postcode'], - 'street' => $row['street'], - 'streetn' => $row['streetnr'], - 'updatetime' => $row['updatetime'], - 'usertype'=>'u', - 'password' => $row['password'] - ); - } - - } else if ($config['sourceType'] == 'whmcs') { - - $sql = "SELECT COUNT(`id`) AS `amount` FROM `tblclients` - WHERE `status`='Active'"; - - $query = $pdo->prepare($sql); - $query->execute(); - $total = $query->fetchColumn(); - - $sql = "SELECT * FROM `tblclients` - WHERE `status`='Active' - LIMIT $start,$chunkSize"; - - $query = $pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - // WHMCS stores street + number so we need to split and rebuild strings - $exploded = preg_split('/\s/', $row["address1"], -1, PREG_SPLIT_NO_EMPTY); - $lastKey = count($exploded) - 1; - - if ($lastKey > -1 and isset($exploded[$lastKey])) { - $streetn = $exploded[$lastKey]); - unset($exploded[$lastKey]); - } else { - $streetn = null; - } - - // the keys needs to be adjusted to your table layout and query! - $json[]=array( - 'externalID' => $config['sourceType'] . ':' . $row['id'], - 'salutation' => null, - 'email' => $row['email'], - 'loginName' => $row['username'], - 'firstName' => $row['firstname'], - 'lastName' => $row['lastname'], - 'birthday' => null, - 'country' => strtolower($row['country']), - 'phone' => $row['phonenumber'], - 'fax' => null, - 'handy' => null, - 'city' => implode(" ", $exploded), - 'cityn' => $streetn, - 'street' => $row['street'], - 'streetn' => $row['streetnr'], - 'updatetime' => $row['updatetime'], - 'usertype'=>'u', - ); - } - - } else if ($config['sourceType'] == 'teklab') { - - $lastID = str_replace($config['sourceType'] . ':', '', $lastID); - - // Get amount of users that are new or received an update - $sql="SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_members` - WHERE `rank`=1"; - $query=$pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // users - $sql = "SELECT * FROM `{$config['tblPrefix']}_members` - WHERE `rank`=1 - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - // Teklab has also 3 for company which Easy-WI currently does not maintain - if ($row['title'] == 0) { - $salutation = 1; - } else if ($row['title']==1) { - $salutation = 2; - } else { - $salutation = null; - } - - // Easy-WI uses ISO code for storing countries - if ($row['country'] == 1) { - $country = 'de'; - } else if ($row['country'] == 2) { - $country = 'uk'; - } else if ($row['country'] == 3) { - $country = 'at'; - } else if ($row['country'] == 4) { - $country = 'ch'; - } else { - $country = null; - } - - // Street and streetnumber are stored in the same column Easy-WI has individual columns - $exploded = explode(" ", $row['street']); - if (count($exploded) > 1) { - $streetNumber = $exploded[count($exploded) - 1]; - unset($exploded[count($exploded) - 1]); - $streetName = implode(' ', $exploded); - } else { - $streetName = null; - $streetNumber = null; - } - - $json[]=array( - 'externalID' => $config['sourceType'] . ':' . $row['id'], - 'salutation' => $salutation, - 'email' => $row['email'], - 'loginName' => $row['member'], - 'firstName' => $row['surname'], - 'lastName' => $row['name'], - 'birthday'=> date('Y-m-d H:m:s', strtotime($row['birthday'])), - 'country' => $country, - 'phone' => $row['phone'], - 'fax' => $row['fax'], - 'handy' => null, - 'city' => $row['city'], - 'cityn' => $row['zipcode'], - 'street' => $streetName, - 'streetn' => $streetNumber, - 'updatetime' => null, - 'usertype'=>'u', - 'password' => $row['password'] - ); - } - } - - } else if ($list == 'rootserver') { - if ($config['sourceType'] == 'teklab') { - - // Get amount of gameservers that are new or received an update - $sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_rootserver` - WHERE `active`=1 - AND `games`=1"; - $query = $pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // gameservers - $sql = "SELECT * FROM `{$config['tblPrefix']}_rootserver` - WHERE `active`=1 - AND `games`=1 - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - $ips = explode("\n", str_replace("\r",'',$row['serverip'])); - $ram = (substr($row['ram'], -2) == 'GB') ? trim(substr($row['ram'], 0, (strlen($row['ram']) - 2))) : round((trim(substr($row['ram'], 0, (strlen($row['ram']) - 2))) / 1024), 2); - - $json[]=array( - 'externalID' => $row['id'], - 'belongsToID' => $row['memberid'], - 'ips' => $ips, - 'sshPort' => $row['sshport'], - 'ftpPort' => $row['ftpport'], - 'cores' => $row['cpucores'], - 'ram' => $ram - ); - } - } - - } else if ($list == 'gameserver') { - if ($config['sourceType'] == 'teklab') { - - // Get amount of gameservers that are new or received an update - $sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_gameserver`"; - $query = $pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // gameservers - $sql = "SELECT u.`member`,u.`ftppasswd`,i.`scriptfolder`,g.* FROM `{$config['tblPrefix']}_gameserver` AS g - INNER JOIN `{$config['tblPrefix']}_members` AS u - ON g.`memberid`=u.`id` - INNER JOIN `{$config['tblPrefix']}_games` AS i - ON i.`sname`=g.`game` - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - $extraPath = (strlen($row['scriptfolder']) > 0) ? $row['scriptfolder'] . '/' : ''; - - $json[]=array( - 'externalID' => $row['id'], - 'belongsToID' => $row['memberid'], - 'rootID' => $row['rserverid'], - 'ip' => $row['serverip'], - 'port' => $row['serverport'], - 'port2' => $row['queryport'], - 'slots' => $row['player'], - 'assignedCore' => ($row['cpucore'] - 1), - 'protectionMode' => ($row['protect'] == 1) ? 'Y' : 'N', - 'tickrate' => $row['gtick'], - 'startMap' => $row['gmap'], - 'shorten' => $row['game'], - 'player' => $row['player'], - 'ftpUser' => $row['member'], - 'ftpPass' => $row['ftppasswd'], - 'path' => 'server/' . $row['path'] . '/' .$extraPath - ); - } - } - - } else if ($list == 'voiceserver') { - if ($config['sourceType'] == 'teklab') { - - // Get amount of voiceservers that are new or received an update - $sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_voiceserver` - WHERE `typ`='Teamspeak3'"; - $query = $pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // voiceservers - $sql = "SELECT * FROM `{$config['tblPrefix']}_voiceserver` - WHERE `typ`='Teamspeak3' - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - if (filter_var($row['serverip'], FILTER_VALIDATE_IP)) { - $ip = $row['serverip']; - $dns = ''; - } else { - $ip = gethostbyname($row['serverip']); - $dns = $row['serverip']; - } - - $json[]=array( - 'externalID' => $row['id'], - 'belongsToID' => $row['memberid'], - 'ip' => $ip, - 'dns' => $dns, - 'port' => $row['serverport'], - 'slots' => $row['slots'] - ); - } - } - } else if ($list == 'voicemaster') { - if ($config['sourceType'] == 'teklab') { - - // Get amount of voiceservers that are new or received an update - $sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_teamspeak` - WHERE `typ`='Teamspeak3'"; - $query = $pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // voiceservers - $sql = "SELECT * FROM `{$config['tblPrefix']}_teamspeak` - WHERE `typ`='Teamspeak3' - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - if (filter_var($row['serverip'], FILTER_VALIDATE_IP)) { - $ip = $row['serverip']; - $dns = ''; - } else { - $ip = gethostbyname($row['serverip']); - $dns = $row['serverip']; - } - - $json[]=array( - 'externalID' => $row['id'], - 'belongsToID' => $row['memberid'], - 'ip' => $ip, - 'dns' => $dns, - 'port' => $row['queryport'], - 'queryAdmin' => $row['admin'], - 'queryPassword' => $row['passwd'], - 'sshUser' => 'user-webi', - 'path' => '/home/user-webi/' . $row['path'] . '/' - ); - } - } - - // Substitutes at last so we can get access permissions as well - } else if ($list == 'substitutes') { - if ($config['sourceType'] == 'teklab') { - - // Get amount of substitutes that are new or received an update - $sql = "SELECT COUNT(`id`) AS `amount` FROM `{$config['tblPrefix']}_subusers`"; - $query = $pdo->prepare($sql); - $query->execute(); - $total=$query->fetchColumn(); - - // substitutes - $sql = "SELECT * FROM `{$config['tblPrefix']}_subusers` - LIMIT $start,$chunkSize"; - $query=$pdo->prepare($sql); - - $sql = "SELECT * FROM `{$config['tblPrefix']}_subusers_servers` WHERE `subuserid`=? AND `active`=1"; - $query2 = $pdo->prepare($sql); - - $query->execute(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - $serverAccess = array( - 'de' => array(), - 'gs' => array(), - 'vo' => array(), - 'vs' => array(), - ); - - $query2->execute(array($row['id'])); - foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) { - if ($row2['typ'] == 'games') { - $what = 'gs'; - } else if ($row2['typ'] == 'voice') { - $what = 'vo'; - } else if ($row2['typ'] == 'mvserver') { - $what = 'vs'; - } else if ($row2['typ'] == 'mrserver') { - $what = 'de'; - } else { - $what = $row2['typ']; - } - $serverAccess[$what][] = $row2['typid']; - } - - - $json[] = array( - 'externalID' => $row['id'], - 'belongsToID' => $row['memberid'], - 'loginName' => $row['user'], - 'firstName' => null, - 'lastName' => null, - 'serverAccess' => $serverAccess, - 'password' => $row['password'] - ); - } - } - } - - // Echo the JSON reply with - echo json_encode(array('total' => $total,'entries' => $json)); - - // Catch database error and display - } catch(PDOException $error) { - echo json_encode(array('error' => $error->getMessage())); - } -} \ No newline at end of file diff --git a/external/crud.php b/external/crud.php deleted file mode 100644 index a5694b48..00000000 --- a/external/crud.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * This file is part of Easy-WI. - * - * Easy-WI is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Easy-WI is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Easy-WI. If not, see . - * - * Diese Datei ist Teil von Easy-WI. - * - * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen - * der GNU General Public License, wie von der Free Software Foundation, - * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren - * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. - * - * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber - * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite - * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. - * Siehe die GNU General Public License fuer weitere Details. - * - * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem - * Programm erhalten haben. Wenn nicht, siehe . - */ - - -// Define the ID variable which will be used at the form and SQLs -$id = $ui->id('id', 10, 'get'); - -// Default variables. Mostly needed for the add operation -$defaultVar = ($ui->id('id', 10, 'get')) ? $ui->id('id', 10, 'get') : 10; - -// At this point all variables are defined that can come from the user - -$table = array(); - -// CSFR protection with hidden tokens. If token(true) returns false, we likely have an attack -if ($ui->w('action', 4, 'post') and !token(true)) { - - unset($header, $text); - - $errors = array('token' => $spracheResponse->token); - -} else { - $errors = array(); -} - -if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') { - - // Add jQuery plugin chosen to the header - /* - $htmlExtraInformation['css'][] = ''; - $htmlExtraInformation['js'][] = ''; - */ - - if ($id and $ui->st('d', 'get') == 'md') { - - $query = $sql->prepare("SELECT `a`,b`,`c` FROM `table` WHERE `id`=? AND `reseller_id`=? LIMIT 1"); - $query->execute(array($id, $resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - - if (!$ui->st('action', 'post')) { - $a = $row['a']; - $b = $row['b']; - $c = $row['c']; - } - - $oldA = $row['a']; - $oldB = $row['b']; - $oldC = $row['c']; - } - } - - if (count($errors) == 0 and ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad')) { - - if (!$active) { - $errors['active'] = $sprache->active; - } - - if (count($errors) == 0) { - - if ($ui->st('action', 'post') == 'ad' and isset($rootServer)) { - - $query = $sql->prepare("INSERT INTO `table` (`a`,`b`,`c`,`reseller_id`) VALUES (?,?,?,?)"); - $query->execute(array($a, $b, $c, $resellerLockupID)); - $rowCount = $query->rowCount(); - - $loguseraction = '%add% %yourmodule% ' . $a; - - } else if ($ui->st('action', 'post') == 'md' and $id and isset($rootServer)) { - - $query = $sql->prepare("UPDATE `table` SET `a`=?,`b`=?,`c`=? WHERE `id`=? AND `reseller_id`=? LIMIT 1"); - $query->execute(array($a, $b, $c, $id, $resellerLockupID)); - $rowCount = $query->rowCount(); - - $loguseraction = '%mod% %yourmodule% ' . $a; - } - - if (isset($rowCount) and $rowCount > 0) { - - $insertlog->execute(); - $template_file = $spracheResponse->table_add; - - // No update or insert failed - } else { - $template_file = $spracheResponse->error_table; - } - } - } - - // An error occurred during validation - // unset the redirect information and display the form again - if (!$ui->smallletters('action', 2, 'post') or count($errors) != 0) { - - unset($header, $text); - - // Gather data for adding if needed and define add template - if ($ui->st('d', 'get') == 'ad') { - - $table = getUserList($resellerLockupID); - - $template_file = 'admin_your_module_add.tpl'; - - // Gather data for modding in case we have an ID and define mod template - } else if ($ui->st('d', 'get') == 'md' and $id) { - - // Check if database entry exists and if not display 404 page - $template_file = (isset($oldActive)) ? 'admin_your_module_md.tpl' : 'admin_404.tpl'; - - // Show 404 if GET parameters did not add up or no ID was given with mod - } else { - $template_file = 'admin_404.tpl'; - } - } - -} else if ($ui->st('d', 'get') == 'dl' and $id) { - - $query = $sql->prepare("SELECT `a`,`b`,`c` FROM `table` WHERE `id`=? AND `reseller_id`=? LIMIT 1"); - $query->execute(array($id, $resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $a = $row['a']; - } - - $serverFound = $query->rowCount(); - - if ($ui->st('action', 'post') == 'dl' and count($errors) == 0 and $serverFound > 0) { - - $query = $sql->prepare("DELETE FROM `table` table `id`=? AND `reseller_id`=? LIMIT 1"); - $query->execute(array($id, $resellerLockupID)); - - if ($query->rowCount() > 0) { - - $loguseraction = '%del% %yourmodule% ' . $a; - $insertlog->execute(); - - $template_file = $spracheResponse->table_del; - } else { - $template_file = $spracheResponse->error_table; - } - } - - // Nothing submitted yet or csfr error, display the delete form - if (!$ui->st('action', 'post') or count($errors) != 0) { - // Check if we could find an entry and if not display 404 page - $template_file = ($serverFound > 0) ? 'admin_your_module_dl.tpl' : 'admin_404.tpl'; - } - -} else { - - configureDateTables('-1', '1, "asc"', 'ajax.php?w=datatable&d=yourmodule'); - - $template_file = 'admin_your_module_list.tpl'; -} \ No newline at end of file diff --git a/external/easywiapi.php b/external/easywiapi.php deleted file mode 100644 index ba1362c8..00000000 --- a/external/easywiapi.php +++ /dev/null @@ -1,285 +0,0 @@ -timeout=$timeout; - // check if curl is choosen and available and initiate cURL-Session - if ($connect=='curl' and function_exists('curl_init')) { - if ($this->startCurl($url,$ssl,$port)===true) { - $this->connect='curl'; - } - - // Use and or fallback to fsockopen if possible and create socket - } else if (($connect=='fsockopen' or !function_exists('curl_init')) and function_exists('fsockopen')) { - if ($this->startSocket($url,$ssl,$port)===true) { - $this->connect='fsockopen'; - } - } - - // If connection was successfull, go on and set values - if ($this->connect!==false) { - $this->user=$user; - $this->pwd=$pwd; - $this->ssl=$ssl; - $this->port=$port; - $this->url=$url; - // Use json, or xml to communicate - if ($method=='json') { - $this->method='json'; - } else { - $this->method='xml'; - } - } else { - $this->throwException(10); - } - } - - // False usage of the object needs to be handled and execution stopped - private function throwException ($rawError,$extraText=false) { - // If an exception is caught from imbedded class use the raw error - if (is_object($rawError)) { - $errorcode=$rawError->getMessage(); - - // else use the custom messages - } else { - - // default custom messages - $errorArray=array( - 1=>'Bad data: Only Strings and Integers are allowed!', - 2=>'Bad data: Only Strings are allowed!', - 3=>'Bad data: Only Integers are allowed!', - 4=>'Bad data: Only arrays are allowed!', - 5=>'Bad data: Unknown Error!', - 6=>'Bad data: Empty values!', - 10=>'Connection Error: Could not connect to!'.$this->url - ); - - // if the message is not predifined use the raw input - if (array_key_exists($rawError,$errorArray)) { - $errorcode=$errorArray["${rawError}"]; - } else { - $errorcode=$rawError; - } - } - - // Add some extra info if given - if ($extraText!==false) { - $errorcode.=$extraText; - } - throw new Exception('

'.$errorcode.'

'); - die; - } - // - private function startCurl ($url,$ssl,$port) { - // create the URL to call - if (substr($url,-1)=='/') { - $url=substr($url,0,-1); - } - $url=str_replace(array('http://','https://',':8080',':80',':443'),'',$url); - if ($ssl==true) { - $url='https://'.$url; - } else { - $url='http://'.$url; - } - $url=$url.'/api.php'; - - // create cURL-Handle - $this->handle=curl_init($url); - - // check success - if ($this->handle===false) { - return false; - } else { - - // Set options - $this->setbasicCurlOpts(); - return true; - } - } - - // in case of curl setopts - private function setbasicCurlOpts () { - curl_setopt($this->handle,CURLOPT_CONNECTTIMEOUT,$this->timeout); - curl_setopt($this->handle,CURLOPT_USERAGENT,"cURL (Easy-WI; 1.0; Linux)"); - curl_setopt($this->handle,CURLOPT_RETURNTRANSFER,true); - curl_setopt($this->handle,CURLOPT_SSL_VERIFYPEER,false); - curl_setopt($this->handle,CURLOPT_FOLLOWLOCATION,1); - curl_setopt($this->handle,CURLOPT_HEADER,1); - //curl_setopt($this->handle,CURLOPT_ENCODING,'deflate'); - if (($this->ssl===true and $this->port!=443) or ($this->ssl===false and $this->port!=80)) { - curl_setopt($this->handle,CURLOPT_PORT,$this->port); - } - } - - // method to execute a curl request - private function execCurl($type,$send) { - - // Setting up POST data and add it to the opts - $postArray['user']=$this->user; - $postArray['pwd']=$this->pwd; - $postArray['type']=$type; - $postArray['xmlstring']=$send; - curl_setopt($this->handle,CURLOPT_POSTFIELDS,$postArray); - - // Execute request, get the response and return it. - $this->response=curl_exec($this->handle); - $this->header=curl_getinfo($this->handle); - return $this->response; - } - - // Ioncube obfuscated files add sometimes data to the REST responses. - // This will be picked up if fsockopen is used. - // So there is a need to strip this data. - private function convertRawData ($rawdata) { - if ($this->method=='json') { - $checkStart='{'; - $checkStop='}'; - } else { - $checkStart='<'; - $checkStop='>'; - } - $response=$rawdata; - while (substr($response,0,1)!=$checkStart and strlen($response)>0) { - $response=substr($response,1); - } - while (substr($response,-1)!=$checkStop and strlen($response)>0) { - $response=substr($response,0,-1); - } - - // Decode the rest of the response string into an object. - if ($this->method=='json') { - $decoded=@json_decode($response); - } else { - $decoded=@simplexml_load_string($response); - } - - // If decoding was not possible return the raw response, else return the object. - if ($decoded) { - unset($rawdata); - return $decoded; - } else if ($this->connect=='fsockopen') { - return substr($rawdata,4,-3); - } else { - return $rawdata; - } - unset($decoded); - } - - // create the JSON that will be send to the API - private function JSONPostValue ($paramArray,$action,$params) { - $jsonArray=array(); - foreach ($paramArray as $param) { - if (array_key_exists($param,$params)) { - if (is_array($params[$param])) { - $jsonArray[$param]=array(); - foreach ($params[$param] as $val) { - $jsonArray[$param][]=$params[$param]; - } - } else { - $jsonArray[$param]=$params[$param]; - } - } else { - $jsonArray[$param]=''; - } - } - $json=json_encode($jsonArray); - unset($type,$params,$paramArray,$jsonArray); - return $json; - } - - // create the XML that will be send to the API - private function XMLPostValue ($paramArray,$action,$params) { -$xml=new SimpleXMLElement(<< - -XML -); - foreach ($paramArray as $param) { - if (array_key_exists($param,$params)) { - if (is_array($params[$param])) { - foreach ($params[$param] as $val) { - $xml->addChild($param,$val); - } - } else { - $xml->addChild($param,$params[$param]); - } - } else { - $jsonArray[$param]=''; - } - } - unset($type,$params,$paramArray); - return $xml; - } - - - // Method the external script calls - public function makeRestCall($type,$action,$params) { - - // some param validation. On fail throw an exception - if (!is_string($type)) { - $this->throwException(2,': $type'); - } - if (!is_string($action)) { - $this->throwException(2,': $action'); - } - if (!is_array($params)) { - $this->throwException(4,': $params'); - } - if (!in_array($type,array('user','gserver','mysql','voice','restart'))) { - $this->throwException('Error: $type is not defined correctly. Allowed methods are (user, gserver, mysql, vserver, restart)'); - } - if (!in_array($action,array('mod','add','del','ls','st','re'))) { - $this->throwException('Error: $action is not defined correctly. Allowed methods are (md, ad, dl, st, re, list)'); - } - - // Array keys that all methods have in common - $generalArray=array('username','user_localid','active'); - - // Array keys server have in common - $generalServerArray=array('identify_user_by','user_externalid','identify_server_by','server_external_id','server_local_id','master_server_id','master_server_external_id'); - - // Keys specfic to user - $paramArray['user']=array('identify_by','external_id','localid','email','password'); - - // Keys specfic to gserver - $paramArray['gserver']=array('private','shorten','slots','primary','taskset','cores','eacallowed','tvenable','pallowed','opt1','opt2','opt3','opt4','opt5','port2','port3','port4','port5','minram','maxram','brandname'); - - // Keys specfic to voice - $paramArray['voice']=array('private','shorten','slots','max_download_total_bandwidth','max_upload_total_bandwidth','maxtraffic','forcebanner','forcebutton','forceservertag','forcewelcome'); - - // Keys specfic to mysql - $paramArray['mysql']=array(); - - // create the post value - if ($this->method=='json') { - $post=$this->JSONPostValue(array_unique(array_merge($generalArray,$generalServerArray,$paramArray[$type])),$action,$params); - } else { - $post=$this->XMLPostValue(array_unique(array_merge($generalArray,$generalServerArray,$paramArray[$type])),$action,$params); - } - - // Call method to send the data depending on the connection type - if ($this->connect=='curl' and is_recource($this->handle)) { - $this->execCurl($type,$post); - } else if ($this->connect=='fsockopen' and is_recource($this->handle)) { - fclose($this->handle); - } else { - $this->throwException(10); - } - } - - // destructor - __destruct () { - if ($this->connect=='curl' and is_recource($this->handle)) { - curl_close($this->handle); - } else if ($this->connect=='fsockopen' and is_recource($this->handle)) { - fclose($this->handle); - } - unset($method,$timeout,$connect,$user,$pwd,$handle,$ssl,$port,$response); - } -} \ No newline at end of file diff --git a/external/easywiapitest.php b/external/easywiapitest.php deleted file mode 100644 index 982115d7..00000000 --- a/external/easywiapitest.php +++ /dev/null @@ -1,177 +0,0 @@ - - - - $action - localid - - 26 - $localID - 570 - testing2@mail.de - - Y - -XML; -} else if ($_GET['test']=='gserver') { -$type = 'gserver'; -$postxml = << - - - $action - user_localid - server_local_id - - - $userID - css - cstrike - cstrike - 12 - re - N - - $localID - N - - - - - - - - - 123 - - - - - 2000 - 2001 - 2003 - 2004 - - - - - -XML; -if(isset($_GET['restart']) and $_GET['restart']=='re' or $_GET['st']) { -$restart=$_GET['restart']; -$postxml = << - - - $action - server_local_id - $restart - - $localID - -XML; -} -} else if ($_GET['test']=='voice') { -$type = 'voice'; -$postxml = << - - - $action - user_localid - server_local_id - - - $userID - ts3 - 12 - N - - $localID - N - 44 - - - - - - - - - -XML; -} else { - echo '
';
-	print_r();
-	echo '
';
-}
-if (!isset($stop)) {
-	if (isset($postxml)) echo $postxml.'
'; - $data = 'pwd='.urlencode($pwd).'&user='.$user.'&xml='.urlencode(base64_encode($postxml)).'&type='.$type; - $useragent=$_SERVER['HTTP_HOST']; - $fp = @fsockopen($host, 80, $errno, $errstr, 30); - $buffer=""; - if ($fp) { - $send = "POST ".$path." HTTP/1.1\r\n"; - $send .= "Host: ".$host."\r\n"; - $send .="User-Agent: $useragent\r\n"; - $send .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"; - $send .= "Content-Length: ".strlen($data)."\r\n"; - $send .= "Connection: Close\r\n\r\n"; - $send .= $data; - fwrite($fp, $send); - while (!feof($fp)) { - $buffer .= fgets($fp, 1024); - } - fclose($fp); - } - list($header,$response)=explode("\r\n\r\n",$buffer); - $raw=$response; - $header=str_replace(array("\r\n","\r"),"\n",$header); - $header=str_replace("\t",' ',$header); - $ex=explode("\n",$header); - list($type,$errocode,$errortext)=explode(' ',$ex[0]); - echo 'Here comes the response:
';
-	if ($errocode>400) {
-		print_r(substr($response,4,-3));	
-	} else {
-		while(substr($response,0,1)!='<' and strlen($response)>0) {
-			$response=substr($response,1);
-		}
-		while(substr($response,-1)!='>' and strlen($response)>0) {
-			$response=substr($response,0,-1);
-		}
-		$object=@simplexml_load_string($response);
-		if ($object) {
-			echo '
';
-			print_r($object);
-			echo '
'; - } else { - echo 'Could not decode response
'; - echo $raw; - } - } -} \ No newline at end of file diff --git a/external/external_auth.php b/external/external_auth.php deleted file mode 100644 index 755bc2db..00000000 --- a/external/external_auth.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * This file is part of Easy-WI. - * - * Easy-WI is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Easy-WI is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Easy-WI. If not, see . - * - * Diese Datei ist Teil von Easy-WI. - * - * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen - * der GNU General Public License, wie von der Free Software Foundation, - * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren - * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. - * - * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber - * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite - * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. - * Siehe die GNU General Public License fuer weitere Details. - * - * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem - * Programm erhalten haben. Wenn nicht, siehe . - */ - -$dbName='name'; -$dbUser='user'; -$dbPwd='pwd'; -$dbHost='localhost'; -$configUser='meinUsername'; -$configPass='meinPasswort'; - -if (!isset($_POST['postXML'])) { - $bad='No XML has been send'; -} - -if (!isset($bad) and isset($_POST['authPWD']) and isset($_POST['userAuth']) and $_POST['authPWD']==$configPass and $_POST['userAuth']==$configUser) { - // postXML into object - $xml= @simplexml_load_string(base64_decode($_POST['postXML'])); - if($xml) { - $user=$xml->user; - $pwd=$xml->pwd; - $mail=$xml->mail; - $externalID=$xml->externalID; - - // use whatever your system does to hash passwords. Only MD5 is common but bad practise - $hashedPWD=md5($pwd); - - // DB Connection and search user - try { - $connection=new PDO("mysql:host=$dbHost;dbname=$dbName",$dbUser,$dbPwd); - $connection->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); - - // This is just an example! Needs to be fitted to your database structure! - $query=$connection->prepare("SELECT `pwd` FROM `tbl_userdata` WHERE `loginname`=? LIMIT 1"); - $query->execute(array($user)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - $storedHash=$row['pwd']; - } - - /* WHMCS is look like: - $query=$connection->prepare("SELECT `password` FROM `tblclients` WHERE `email`=? LIMIT 1"); - $query->execute(array($mail)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - @list($storedHash, $salt) = explode(':', $row['password']); - if (isset($salt)) { - $hashedPWD = md5($pwd . $salt); - } - } - */ - } - catch(PDOException $error) { - $bad=$error->getMessage(); - } - if (!isset($bad) and $hashedPWD==$storedHash) { - $responseXML = << - - - $user - 1 - -XML; - } else if (!isset($bad)) { - $bad='bad login data.'; - } - } else { - $bad='No valid XML data has been send'; - } -} else { - $bad='Bad API auth data.'; -} -header("Content-type: text/xml"); -if(isset($bad)) { - $responseXML = << - - - - 0 - $bad - -XML; -} -echo $responseXML; \ No newline at end of file diff --git a/external/external_protectioncheck.php b/external/external_protectioncheck.php deleted file mode 100644 index 31a532ea..00000000 --- a/external/external_protectioncheck.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * This file is part of Easy-WI. - * - * Easy-WI is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Easy-WI is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Easy-WI. If not, see . - * - * Diese Datei ist Teil von Easy-WI. - * - * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen - * der GNU General Public License, wie von der Free Software Foundation, - * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren - * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. - * - * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber - * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite - * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. - * Siehe die GNU General Public License fuer weitere Details. - * - * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem - * Programm erhalten haben. Wenn nicht, siehe . - */ - - -if (isset($_POST['adresse'])) { - $fail=0; - $adresse=explode(":", $_POST['adresse']); - if(isset($adresse['0']) and filter_var($adresse['0'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) and preg_match("/^(0|([1-9]\d{0,3}|[1-5]\d{4}|[6][0-5][0-5]([0-2]\d|[3][0-5])))$/", $adresse['1'])){ - $ip=$adresse['0']; - $port=$adresse['1']; - } else { - $fail=1; - } - if ($fail == '0') { - // If you need a yes or no following is sufficient: - $status=file_get_contents("https://webinterface.domain.tld/protectioncheck.php?ip=$ip&po=$port"); - } else { - echo "formular"; - if ( $status == 'yes' ) { - echo "Server ist geschützt"; - } else if ( $status == 'no' ) { - echo "Server ist ungeschützt"; - } else if ( $status == 'unknown' ) { - echo "Ein Server mit dieser IP wurde nicht gefunden bitte versuche es erneut:"; - } - } else { - echo "hier das Formular ausgeben"; - } - // In case you need status information and or the log: - libxml_set_streams_context(stream_context_create(array('http'=>array('user_agent'=>'PHP libxml agent',null)))); - $xml = simplexml_load_file("https://webinterface.domain.tld/protectioncheck.php?ip=$ip&po=$port&gamestring=xml"); - if ($xml != 'unknown') { - echo $xml->hostname.'
'; - echo $xml->gametype.'
'; - echo $xml->map.'
'; - echo $xml->numplayers.'
'; - echo $xml->maxplayers.'
'; - echo $xml->protection.'
'; - if ($xml->psince != '0000:00:00') { - echo $xml->psince.'
'; - } - foreach ($xml->actions->action as $action) { - echo $action->time.' '.$action->log.'
'; - } - } -} else { -?> -
- - - - - -
-
- - diff --git a/server/control.sh b/server/control.sh deleted file mode 100644 index 887a9552..00000000 --- a/server/control.sh +++ /dev/null @@ -1,2406 +0,0 @@ -#!/bin/bash - -# Author: Ulrich Block -# -# This file is part of Easy-WI. -# -# Easy-WI is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Easy-WI is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Easy-WI. If not, see . -# -# Diese Datei ist Teil von Easy-WI. -# -# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen -# der GNU General Public License, wie von der Free Software Foundation, -# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren -# veroeffentlichten Version, weiterverbreiten und/oder modifizieren. -# -# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber -# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite -# Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. -# Siehe die GNU General Public License fuer weitere Details. -# -# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -# Programm erhalten haben. Wenn nicht, siehe . - - -if [ "$1" == "install" ]; then - TOOLS=('adduser' 'awk' 'basename' 'bzip2' 'cat' 'chmod' 'chown' 'deluser' 'dirname' 'find' 'grep' 'groupadd' 'id' 'ionice' 'lsof' 'mkdir' 'mv' 'pwd' 'rm' 'rsync' 'sleep' 'tar' 'touch' 'tr' 'useradd' 'userdel' 'usermod' 'wget' 'wput' 'zip') - for TOOL in ${TOOLS[@]}; do - if command -v $TOOL >/dev/null 2>&1; then echo "required tool found: $TOOL"; else echo "required tool not found or no access to it: $TOOL"; fi - done -fi -CVERSION="4.9" -IONICE='' -HOMEFOLDER=$PWD -LOGDIR=$HOMEFOLDER/logs -DATADIR=$HOMEFOLDER/fdl_data -MAPDIR=$HOMEFOLDER/mastermaps -ADDONDIR=$HOMEFOLDER/masteraddons -MASTERSERVERDIR=$HOMEFOLDER/masterserver -TEMPFOLDER=$HOMEFOLDER/temp -VARIABLE0="$0" -VARIABLE1="$1" -VARIABLE2="$2" -VARIABLE3="$3" -VARIABLE4="$4" -VARIABLE5="$5" -VARIABLE6="$6" -VARIABLE7="$7" -VARIABLE8="$8" -VARIABLE9="$9" -VARIABLE10="${10}" -VARIABLEALL="$@" -SCRIPTNAME=`basename $0` -MASTERUSER=`echo $HOMEFOLDER | awk -F "/" '{print $3}'` -NOUPDATES=`grep NOUPDATES $HOMEFOLDER/conf/config.cfg 2> /dev/null | awk -F "=" '{print $2}' | tr -d '"'` -IONICEALLOWED=`grep IONICE $HOMEFOLDER/conf/config.cfg 2> /dev/null | awk -F "=" '{print $2}' | tr -d '"'` -if [ "$SCRIPTNAME" == "control" ]; then - cp control control.sh - chmod +x control.sh -fi -if [ "$IONICEALLOWED" == "1" ]; then - if ionice -c3 true 2>/dev/null; then IONICE='ionice -n 7 '; fi -fi -if [ "`id -u`" != "0" ]; then screen -wipe > /dev/null 2>&1; fi -function wget_remove { - if [ "`id -u`" != "0" -a "`id -u`" == "`id -u $MASTERUSER`" ]; then - RETRY=0 - while [ -f $HOMEFOLDER/.updateLock -a "$RETRY" -lt 10 ]; do - sleep 0.5 - RETRY=$[RETRY+1] - done - if [ "$RETRY" -lt 10 ]; then - rm -f wget-log > /dev/null 2>&1 - find $HOMEFOLDER -maxdepth 1 -name "control_new.*" -delete - find $HOMEFOLDER \( -iname "wget-*" \) -delete - find $HOMEFOLDER/conf/ -maxdepth 1 -name "wget-*" -delete - find $HOMEFOLDER/logs/ $HOMEFOLDER/temp/ $HOMEFOLDER/fdl_data/ -type d -user `whoami` -print0 | xargs -0 chmod 770 - fi - fi -} -function updatecheck { - if [ ! -f $HOMEFOLDER/.updateLock ]; then - touch $HOMEFOLDER/.updateLock - if [ "$ISROOT" == "0" ]; then - LOGFILES=(addons hl2 server fdl update fdl-hl2) - for LOGFILE in ${LOGFILES[@]}; do - if [ "$LOGFILE" != "" -a ! -f "$LOGDIR/$LOGFILE.log" ]; then touch "$LOGDIR/$LOGFILE.log"; fi - if [ -f "$LOGDIR/$LOGFILE.log" ]; then chmod 660 "$LOGDIR/$LOGFILE.log"; fi - done - fi - CURRENTFDLVERSION=`wget -q --timeout=10 -O - http://update.easy-wi.com/if_version.php | sed 's/^\xef\xbb\xbf//g'` - if [ -z $CURRENTFDLVERSION ]; then - cd $HOMEFOLDER - if [ -f $HOMEFOLDER/control_new.tar ]; then rm -f $HOMEFOLDER/control_new.tar; fi - elif [ "$CVERSION" != "$CURRENTFDLVERSION" ]; then - if [ "$ISROOT" == "1" ]; then echo "control.sh is outdated fetching update"; fi - cd $HOMEFOLDER - if [ -f $HOMEFOLDER/control_new.tar ]; then rm -f $HOMEFOLDER/control_new.tar; fi - wget -q --timeout=10 http://update.easy-wi.com/programs/bash/control_new.tar - if [ -f $HOMEFOLDER/control_new.tar ]; then - tar xfp control_new.tar - if [ -f $HOMEFOLDER/control_new.sh ]; then - if [[ `$HOMEFOLDER/control_new.sh 2> /dev/null | grep 'Current version'` ]]; then - if [ -f $HOMEFOLDER/control_new.sh ]; then - mv $HOMEFOLDER/control.sh $HOMEFOLDER/control.old.$CVERSION.sh - mv $HOMEFOLDER/control_new.sh $HOMEFOLDER/control.sh - if [ "$ISROOT" == "0" ]; then echo "`date`: Updated the controlprogram from $CVERSION version to $CURRENTFDLVERSION" >> $LOGDIR/update.log; fi - fi - chmod 750 control.sh - fi - fi - if [ ! -f $HOMEFOLDER/control.sh ]; then - OLDVERSION=`ls $HOMEFOLDER/control.old.*.sh | sort -f -r | head -n1` - if [ "$OLDVERSION" != "" ]; then mv $OLDVERSION $HOMEFOLDER/control.sh; fi - fi - rm -f control_new.tar control_new.tar.* control_new.sh control.tar.* control.old.2.3.* 2> /dev/null - fi - if [ "$ISROOT" == "1" ]; then echo "control.sh has been updated to version $CURRENTFDLVERSION."; fi - fi - rm -f $HOMEFOLDER/.updateLock - fi -} -if [ "$NOUPDATES" != "1" -a "$SCRIPTNAME" != "control_new.sh" -a "$VARIABLE1" != "fixpermissions" ]; then - if [ "`id -u`" != "0" -a "`id -u`" == "`id -u $MASTERUSER`" ]; then - ISROOT=0 - updatecheck& - elif [ "`id -u`" == "0" ]; then - ISROOT=1 - updatecheck - if [ "`find -maxdepth 1 -name \"control.old.*\"`" != "" ]; then - rm -f control.old.* - fi - fi -fi -function rsyncExists { -if [ "$VARIABLE1" == "syncaddons" -o "$VARIABLE1" == "syncserver" ]; then - IMAGESERVER=$VARIABLE2 -else - IMAGESERVER=$VARIABLE5 -fi -if [ "$IMAGESERVER" == "none" ]; then - SYNCTOOL='none' -elif [ "$IMAGESERVER" == "" -o "$IMAGESERVER" == "easywi" ]; then - if [ "`which rsync`" != "" ]; then - SYNCTOOL='rsync' - SYNCCMD="rsync -azuvx 84.200.78.232::easy-wi" - else - SYNCTOOL='wget' - SYNCCMD="wget -r -N -l inf -nH --no-check-certificate --cut-dirs=1 ftp://imageuser:BMpRP4HEORkKGj@84.200.78.232" - fi -else - if [ "`which rsync`" != "" -a "`echo $IMAGESERVER | grep -E '^ftp(s|)\:(.*)'`" == "" ]; then - SYNCTOOL='rsync' - SYNCCMD="rsync -azuvx $IMAGESERVER" - else - SYNCTOOL='wget' - SYNCCMD="wget -r -N -l inf -nH --no-check-certificate --cut-dirs=1 $IMAGESERVER" - fi -fi -} -function install_control { -echo "Control Version is: $CVERSION" -if [ "`id -u`" != "0" ]; then echo "You need to be root, to to use the install function"; exit 0; fi -if [ "$VARIABLE3" == "" ]; then - echo "Please enter the name of the masteruser" - read INSTALLMASTER -else - INSTALLMASTER=$VARIABLE3 -fi -if [ "$INSTALLMASTER" == "" ]; then - echo "Error: Masteruser Value is empty. Shutting down to prevent corrupted config and ini files" - exit 0 -fi -if [ "`grep \"$INSTALLMASTER:\" /etc/passwd | awk -F ":" '{print $1}'`" != "$INSTALLMASTER" ]; then - if [ -d /home/$INSTALLMASTER ]; then - groupadd $INSTALLMASTER - /usr/sbin/useradd -d /home/$INSTALLMASTER -s /bin/bash -g $INSTALLMASTER $INSTALLMASTER - else - groupadd $INSTALLMASTER - /usr/sbin/useradd -m -b /home -s /bin/bash -g $INSTALLMASTER $INSTALLMASTER - fi - if [ "$VARIABLE2" != "yesall" ]; then - echo "Set password for the user? It is not needed if you connect with a more secure keyfile!" - echo "Enter yes if you want to set it:" - read READPASSWORD - if [ "$READPASSWORD" == "yes" ]; then - passwd $INSTALLMASTER - else - publicKeyGenerate - fi - elif [ "$VARIABLE4" != "" ]; then - /usr/sbin/usermod -p `perl -e 'print crypt("'$VARIABLE4'","Sa")'` $INSTALLMASTER - fi -else - echo "User found setting group \"$INSTALLMASTER\" as mastegroup" - usermod -g $INSTALLMASTER $INSTALLMASTER -fi -if [[ ! `grep "^${INSTALLMASTER}:" /etc/passwd` ]]; then - echo "Error: User $INSTALLMASTER could not be installed. Shutting down to prevent corrupted config and ini files." - exit 0 -fi -chown -R $INSTALLMASTER:$INSTALLMASTER /home/$INSTALLMASTER/ -chmod -R 750 /home/$INSTALLMASTER/ -sleep 1 -echo "Creating folders and files" -CREATEDIRS=('conf' 'fdl_data/hl2' 'logs' 'masteraddons' 'mastermaps' 'masterserver' 'temp') -for CREATEDIR in ${CREATEDIRS[@]}; do - echo "Adding dir: /home/$INSTALLMASTER/$CREATEDIR" - mkdir -p /home/$INSTALLMASTER/$CREATEDIR -done -chmod -R 750 /home/$INSTALLMASTER/ -chmod -R 770 /home/$INSTALLMASTER/logs/ /home/$INSTALLMASTER/temp/ /home/$INSTALLMASTER/fdl_data/ -LOGFILES=('addons' 'hl2' 'server' 'fdl' 'update' 'fdl-hl2') -for LOGFILE in ${LOGFILES[@]}; do - touch "/home/$INSTALLMASTER/logs/$LOGFILE.log" -done -chmod 660 /home/$INSTALLMASTER/logs/*.log -if [ -f /etc/debian_version ]; then - if [ "$VARIABLE2" == "yesall" ]; then - INSTALLPACKAGES="yes" - else - echo "You are running Debian `cat /etc/debian_version`. Enter yes if you want to install the neccessary packages if needed" - read INSTALLPACKAGES - fi - if [ "$INSTALLPACKAGES" == "yes" ]; then - apt-get update - if [ "$VARIABLE2" == "yesall" ]; then - apt-get upgrade -y - echo "proftpd-basic shared/proftpd/inetd_or_standalone select standalone" | debconf-set-selections - apt-get install wget wput screen bzip2 sudo rsync -y - if [ "`uname -m`" == "x86_64" ]; then - if [[ `cat /etc/debian_version | grep '7.'` ]]; then - dpkg --add-architecture i386 - apt-get update - fi - apt-get install ia32-libs -y - fi - else - apt-get upgrade - apt-get install wget wput screen bzip2 sudo rsync - if [ "`uname -m`" == "x86_64" ]; then - if [[ `cat /etc/debian_version | grep '7.'` ]]; then - dpkg --add-architecture i386 - apt-get update - fi - apt-get install ia32-libs lib32readline5 lib32ncursesw5 - apt-get install lib32gcc1 libgcc1:i386 lib32readline5 libreadline5:i386 lib32ncursesw5 libncursesw5:i386 - else - apt-get install libreadline5 libncursesw5 - fi - fi - fi - if [ "$VARIABLE2" == "yesall" ]; then - PROFTPD="yes" - else - echo "The recommended FTP Server is proftpd. It will be installed if you enter yes" - read PROFTPD - fi - if [ "$PROFTPD" == "yes" ]; then - if [ "$VARIABLE2" == "yesall" ]; then - apt-get install proftpd -y - ADDFTPRULES="yes" - else - apt-get install proftpd - echo "Add FTP rules? You might need to enhance them later. Enter \"yes\" or \"no\"" - read ADDFTPRULES - fi - if [ "`grep '^\s*DefaultRoot\s*\~' /etc/proftpd/proftpd.conf`" == "" ]; then - echo ' -DefaultRoot ~ -' >> /etc/proftpd/proftpd.conf - fi - if [ "`grep 'Include\s*\/etc\/proftpd\/conf.d\/' /etc/proftpd/proftpd.conf`" == "" ]; then - echo ' -Include /etc/proftpd/conf.d/ -' >> /etc/proftpd/proftpd.conf - fi - if [ "$ADDFTPRULES" == "yes" -a "`grep '' /etc/proftpd/proftpd.conf`" == "" -a ! -f "/etc/proftpd/conf.d/easy-wi.conf" ]; then - if [ ! -d "/etc/proftpd/conf.d/" ]; then - mkdir -p "/etc/proftpd/conf.d/" - chmod 755 "/etc/proftpd/conf.d/" - fi - echo ' - - HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on - - DenyAll - -' > /etc/proftpd/conf.d/easy-wi.conf -echo "" >> /etc/proftpd/conf.d/easy-wi.conf -echo ' HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - HideNoAccess on - Umask 137 027 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 177 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - HideFiles (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - - -' >> /etc/proftpd/conf.d/easy-wi.conf - fi - if [ -f /etc/init.d/proftpd ]; then /etc/init.d/proftpd restart; fi - fi -fi -if [ -f /etc/sudoers -a "`grep $INSTALLMASTER /etc/sudoers`" == "" ]; then -echo " -$INSTALLMASTER ALL = NOPASSWD: /usr/sbin/useradd -$INSTALLMASTER ALL = NOPASSWD: /usr/sbin/userdel -$INSTALLMASTER ALL = NOPASSWD: /usr/sbin/deluser -$INSTALLMASTER ALL = NOPASSWD: /usr/sbin/usermod -$INSTALLMASTER ALL = (ALL, !root:$INSTALLMASTER) NOPASSWD: /home/$INSTALLMASTER/control.sh -$INSTALLMASTER ALL = (ALL, !root:$INSTALLMASTER) NOPASSWD: /home/$INSTALLMASTER/temp/*.sh" >> /etc/sudoers -if [ "`which setquota 2> /dev/null`" != "" ]; then echo "$INSTALLMASTER ALL = NOPASSWD: `which setquota`" >> /etc/sudoers; fi -if [ "`which repquota 2> /dev/null`" != "" ]; then echo "$INSTALLMASTER ALL = NOPASSWD: `which repquota`" >> /etc/sudoers; fi -fi - -mv $HOMEFOLDER/control.sh /home/$INSTALLMASTER/control.sh -chmod 770 /home/$INSTALLMASTER/control.sh -cd /home/$INSTALLMASTER/masterserver -echo "Downloading SteamCmd" -mkdir -p /home/$INSTALLMASTER/masterserver/steamCMD/ -cd /home/$INSTALLMASTER/masterserver/steamCMD/ -wget -q --timeout=10 http://media.steampowered.com/client/steamcmd_linux.tar.gz -if [ -f steamcmd_linux.tar.gz ]; then - tar xfvz steamcmd_linux.tar.gz - rm -f steamcmd_linux.tar.gz - chown -R $INSTALLMASTER:$INSTALLMASTER /home/$INSTALLMASTER/ - su -c "./steamcmd.sh +login anonymous +quit" $INSTALLMASTER -fi -sleep 1 -chown -R $INSTALLMASTER:$INSTALLMASTER /home/$INSTALLMASTER -echo "Please add the user $INSTALLMASTER to your AllowUsers entries in the file /etc/ssh/sshd_config" -if [ -d /root/masterserver ]; then - rm -rf /root/masterserver -fi - -if [ "$VARIABLE2" != "yesall" ]; then - echo "Enter yes if you want to install cleanup cronjobs" - read READCRON - - echo "Enter yes if you want the autoupdater being active" - read READUPDATES -fi - -if [ "$VARIABLE2" == "yesall" -o "$READCRON" == "yes" ]; then -if [ -f /etc/crontab ]; then -echo "#Minecraft can easily produce 1GB+ logs within one hour -*/5 * * * * root nice -n +19 ionice -n 7 find /home/*/server/*/*/ -maxdepth 2 -type f -name \"screenlog.0\" -size +100M -delete - -# Even sudo /usr/sbin/deluser --remove-all-files is used some data remain from time to time -*/5 * * * * root nice -n +19 $IONICE find /home/ -maxdepth 2 -type d -nouser -delete -*/5 * * * * root nice -n +19 $IONICE find /home/*/fdl_data/ /home/*/temp/ /tmp/ /var/run/screen/ -nouser -delete" >> /etc/crontab -/etc/init.d/cron restart -fi -fi - -if [ "$READUPDATES" == "yes" ]; then - UPDATES=0 -elif [ "$VARIABLE2" == "yesall" -a "$VARIABLE5" == "noupdates" ]; then - UPDATES=0 -else - UPDATES=1 -fi - -cat > /home/$INSTALLMASTER/conf/config.cfg <> authorized_keys" $INSTALLMASTER - else - cat $KEYNAME >> authorized_keys - fi - else - echo "Error: could not find a key" - fi - fi -} - -function fdlList { - PATTERN="\.log\|\.txt\|\.cfg\|\.vdf\|\.db\|\.dat\|\.ztmp\|\.blib\|log\/\|logs\/\|downloads\/\|DownloadLists\/\|metamod\/\|amxmodx\/\|hl\/\|hl2\/\|cfg\/\|addons\/\|bin\/\|classes/" - echo "PATTERN=$PATTERN" >> $1 - echo "SED=\"sed \"'s/\.\///g'\"\"" >> $1 - echo "if [ -f $HOMEFOLDER/conf/fdl-$UPDATE.list ]; then" >> $1 - echo " rm -f $HOMEFOLDER/conf/fdl-$UPDATE.list" >> $1 - echo 'fi' >> $1 - echo "touch $HOMEFOLDER/conf/fdl-$UPDATE.list" >> $1 - echo "cd $MASTERSERVERDIR/$UPDATE" >> $1 - echo 'if [[ `find -maxdepth 2 -name srcds_run` ]]; then' >> $1 - echo ' cd `find -mindepth 1 -maxdepth 2 -type d -name "$FDLFOLDER" | head -n 1`' >> $1 - echo ' SEARCHFOLDERS="particles/ maps/ materials/ resource/ models/ sound/"' >> $1 - echo ' SEARCH=1' >> $1 - echo 'elif [[ `find -maxdepth 2 -name hlds_run` ]]; then' >> $1 - echo ' cd `find -mindepth 1 -maxdepth 1 -type d -name "$FDLFOLDER" | head -n 1`' >> $1 - echo ' SEARCHFOLDERS=""' >> $1 - echo ' SEARCH=1' >> $1 - echo 'elif [[ `find -maxdepth 2 -name "cod4_lnxded"` ]]; then' >> $1 - echo ' SEARCHFOLDERS="usermaps/ mods/"' >> $1 - echo ' SEARCH=1' >> $1 - echo 'fi' >> $1 - echo 'if [ "$SEARCH" == "1" ]; then' >> $1 - echo "${IONICE}"'nice -n +19 find $SEARCHFOLDERS -type f 2> /dev/null | grep -v "$PATTERN" | $SED | while read FILTEREDFILES; do' >> $1 - echo ' echo $FILTEREDFILES >> $HOMEFOLDER/conf/fdl-'"$UPDATE"'.list' >> $1 - echo ' done' >> $1 - echo "if [ -f $HOMEFOLDER/conf/fdl-$UPDATE.list ]; then" >> $1 - echo " chmod 640 $HOMEFOLDER/conf/fdl-$UPDATE.list" >> $1 - echo 'fi' >> $1 - echo 'if [ -f '"$LOGDIR"'/fdl.log ]; then' >> $1 - echo 'echo "`date`: Updated filelist for the game '"$UPDATE"'" >> '"$LOGDIR"'/fdl.log' >> $1 - echo 'fi' >> $1 - echo 'fi' >> $1 -} - -function steamCmdUpdate { -ps x | grep 'SteamCmdUpdate-Screen' | grep -v 'grep' | awk '{print $1}' | while read PID; do - kill $PID > /dev/null 2>&1 - kill -9 $PID > /dev/null 2>&1 -done -cat > $TEMPFOLDER/updateSteamCmd.sh << EOF -#!/bin/bash -rm -f $TEMPFOLDER/updateSteamCmd.sh -VARIABLE3="$VARIABLE3" -VARIABLE4="$VARIABLE4" -VARIABLE5="$VARIABLE5" -LOGDIR="$LOGDIR" -DATADIR="$DATADIR" -UPDATE="$UPDATE" -HOMEFOLDER="$HOMEFOLDER" -MASTERSERVERDIR="$MASTERSERVERDIR" -cd $MASTERSERVERDIR -EOF -echo "BOMRM=\"sed \"'s/^\xef\xbb\xbf//g'\"\"" >> $TEMPFOLDER/updateSteamCmd.sh -if [ ! -d "$MASTERSERVERDIR/steamCMD/" ]; then - mkdir -p "$MASTERSERVERDIR/steamCMD/" - cd "$MASTERSERVERDIR/steamCMD/" - echo 'if [ ! -f steamcmd.sh ]; then - wget -q --timeout=10 http://media.steampowered.com/client/steamcmd_linux.tar.gz - if [ -f steamcmd_linux.tar.gz ]; then - tar xfz steamcmd_linux.tar.gz - rm -f steamcmd_linux.tar.gz - chmod +x steamcmd.sh - ./steamcmd.sh +login anonymous +quit - fi - fi' >> $TEMPFOLDER/updateSteamCmd.sh -fi - -UPDATECMD="taskset -c 0 $IONICE nice -n +19 ./steamcmd.sh" -if [ "$VARIABLE6" != "" -a "$VARIABLE7" != "" ]; then - UPDATECMD="$UPDATECMD +login $VARIABLE6 $VARIABLE7" -else - UPDATECMD="$UPDATECMD +login anonymous" -fi -I=0 -A=0 -for UPDATE in $VARIABLE3; do - if [ $I == 0 ]; then - DIRCMD=" +force_install_dir $MASTERSERVERDIR/$UPDATE" - GAMENAME=$UPDATE - if [ ! -d "$MASTERSERVERDIR/$UPDATE" ]; then - mkdir -p "$MASTERSERVERDIR/$UPDATE" - fi - if [ "$SYNCTOOL" == 'rsync' ]; then - echo "$SYNCCMD/masterserver/$UPDATE $MASTERSERVERDIR/ > $LOGDIR/steamCmd.log" >> $TEMPFOLDER/updateSteamCmd.sh - elif [ "$SYNCTOOL" == 'wget' ]; then - echo "$SYNCCMD/masterserver/$UPDATE > $LOGDIR/steamCmd-update.log" >> $TEMPFOLDER/updateSteamCmd.sh - echo "${IONICE}nice -n +19 find $MASTERSERVERDIR/$UPDATE -type f -name \"*.listing\" -delete" >> $TEMPFOLDER/updateSteamCmd.sh - fi - echo "`date`: Update started for $UPDATE" >> $LOGDIR/update.log - I=1 - else - if [ "$UPDATE" == "90" ]; then - UPDATECMD="$UPDATECMD $DIRCMD +app_set_config 90 mod $GAMENAME +app_update 90 validate" - else - UPDATECMD="$UPDATECMD $DIRCMD +app_update $UPDATE validate" - fi - I=0 - A=$[A+1] - fi -done -UPDATECMD="$UPDATECMD +quit >> $LOGDIR/steamCmd.log" -if [ $A -gt 0 ]; then -FOLDERS='' -cat >> $TEMPFOLDER/updateSteamCmd.sh << EOF -cd $MASTERSERVERDIR/steamCMD -$UPDATECMD -EOF -echo 'I=0 -for UPDATE in $VARIABLE3; do - if [ $I == 0 ]; then' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' LASTUPDATE=$UPDATE' >> $TEMPFOLDER/updateSteamCmd.sh -echo "${IONICE}"'nice -n +19 find $MASTERSERVERDIR/$UPDATE -maxdepth 2 -type f -name "subscribed_file_ids.txt" -o -name "subscribed_collection_ids.txt" | while read file; do rm -f "$file"; done' >> $TEMPFOLDER/updateSteamCmd.sh -echo "${IONICE}"'nice -n +19 find $MASTERSERVERDIR/$UPDATE -type f \( -iname "srcds_*" -or -iname "hlds_*" -or -iname "*.run" -or -iname "*.sh" \) -print0 | xargs -0 chmod 750' >> $TEMPFOLDER/updateSteamCmd.sh -echo "${IONICE}"'nice -n +19 find $MASTERSERVERDIR/$UPDATE -type f ! -perm -750 ! -perm -755 -print0 | xargs -0 chmod 640' >> $TEMPFOLDER/updateSteamCmd.sh -echo "${IONICE}"'nice -n +19 find $MASTERSERVERDIR/$UPDATE -type d -print0 | xargs -0 chmod 750' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' ls $MASTERSERVERDIR/$UPDATE | while read dir; do' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' if [[ `echo $dir| grep '"'"'[a-z0-9]\{40\}'"'"'` ]]; then' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' rm -rf $MASTERSERVERDIR/$UPDATE/$dir' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' fi' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' done' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' I=1' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' else' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' I=0' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' if [ "`grep $UPDATE $LOGDIR/steamCmd.log` | grep '"'"'Success!'"'"' | grep '"'"'fully installed'"'"'" != "" ]; then' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' SENDUPDATE="YES"' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' fi' >> $TEMPFOLDER/updateSteamCmd.sh -if [ "$VARIABLE2" == "install" ]; then - echo 'SENDUPDATE="YES"' >> $TEMPFOLDER/updateSteamCmd.sh -fi -echo ' if [ "$SENDUPDATE" == "YES" ]; then' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' A=0' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$LASTUPDATE | $BOMRM`' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' while [ "$CHECK" != "ok" -a "$A" -le "10" ]; do' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' if [ "$CHECK" == "" ]; then' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' A=11' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' else' >> $TEMPFOLDER/updateSteamCmd.sh -echo " sleep 30" >> $TEMPFOLDER/updateSteamCmd.sh -echo ' A=$[A+1]' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$LASTUPDATE | $BOMRM`' >> $TEMPFOLDER/updateSteamCmd.sh -echo ' fi' >> $TEMPFOLDER/updateSteamCmd.sh -echo " done" >> $TEMPFOLDER/updateSteamCmd.sh -echo " fi" >> $TEMPFOLDER/updateSteamCmd.sh -echo ' fi' >> $TEMPFOLDER/updateSteamCmd.sh -echo 'done' >> $TEMPFOLDER/updateSteamCmd.sh -fi - -I=0 -for UPDATE in $VARIABLE3; do - if [ $I == 0 ]; then - if [ "$UPDATE" == "css" ]; then - echo "FDLFOLDER='cstrike'">> $TEMPFOLDER/updateSteamCmd.sh - elif [ "$UPDATE" == "dods" ]; then - echo "FDLFOLDER='dod'">> $TEMPFOLDER/updateSteamCmd.sh - elif [ "$UPDATE" == "gmod" ]; then - echo "FDLFOLDER='garrysmod'">> $TEMPFOLDER/updateSteamCmd.sh - else - echo "FDLFOLDER='$UPDATE'">> $TEMPFOLDER/updateSteamCmd.sh - fi - fdlList $TEMPFOLDER/updateSteamCmd.sh $UPDATE - I=1 - else - I=0 - fi -done -chmod +x $TEMPFOLDER/updateSteamCmd.sh -screen -d -m -S SteamCmdUpdate-Screen $TEMPFOLDER/updateSteamCmd.sh -} - -function noSteamCmdUpdate { -if [ "$VARIABLE5" == "" -o "$VARIABLE4" == "easywi" ]; then - VARIABLE4="ftp://imageuser:BMpRP4HEORkKGj@84.200.78.232" -fi -for UPDATE in $VARIABLE3; do - SAVEAS=`echo "$UPDATE" | awk -F ';' '{print $2}'` - DOWNLOADURL=`echo "$UPDATE" | awk -F ';' '{print $3}'` - UPDATE=`echo "$UPDATE" | awk -F ';' '{print $1}'` - if [ "$UPDATE" == "css" ]; then - FDLFOLDER='cstrike' - elif [ "$UPDATE" == "dods" ]; then - FDLFOLDER='dod' - elif [ "$UPDATE" == "gmod" ]; then - FDLFOLDER='garrysmod' - else - FDLFOLDER='$UPDATE' - fi - if [[ ! `screen -ls | grep $UPDATE.update` ]]; then -cat > $TEMPFOLDER/update_$UPDATE.sh << EOF -#!/bin/bash -rm -f $TEMPFOLDER/update_$UPDATE.sh -VARIABLE4="$VARIABLE4" -VARIABLE5="$VARIABLE5" -LOGDIR="$LOGDIR" -DATADIR="$DATADIR" -UPDATE="$UPDATE" -HOMEFOLDER="$HOMEFOLDER" -MASTERSERVERDIR="$MASTERSERVERDIR" -cd "$MASTERSERVERDIR" -FDLFOLDER="$FDLFOLDER" -I=0 -EOF - # Create folder if needed - echo "BOMRM=\"sed \"'s/^\xef\xbb\xbf//g'\"\"" >> $TEMPFOLDER/update_$UPDATE.sh - echo 'if [ ! -d $UPDATE ]; then mkdir -p $UPDATE; fi' >> $TEMPFOLDER/update_$UPDATE.sh - - # Retreive files from mirror and clean up afterwards - if [ "$SYNCTOOL" == 'rsync' ]; then - echo "$SYNCCMD/masterserver/$UPDATE $MASTERSERVERDIR/ > $LOGDIR/update-$UPDATE.log" >> $TEMPFOLDER/update_$UPDATE.sh - elif [ "$SYNCTOOL" == 'wget' ]; then - echo "$SYNCCMD/masterserver/$UPDATE > $LOGDIR/update-$UPDATE.log" >> $TEMPFOLDER/update_$UPDATE.sh - echo "${IONICE}"'nice -n +19 find $MASTERSERVERDIR/$UPDATE -type f -name "*.listing" -delete' >> $TEMPFOLDER/update_$UPDATE.sh - fi - - # Neither HLDS nor steamCmd - FDLFOLDER="$UPDATE" - if [ "$VARIABLE1" == "mcUpdate" ]; then - echo 'cd $UPDATE' >> $TEMPFOLDER/update_$UPDATE.sh - echo "wget $DOWNLOADURL --output-document $SAVEAS" >> $TEMPFOLDER/update_$UPDATE.sh - echo "chmod 750 $SAVEAS" >> $TEMPFOLDER/update_$UPDATE.sh - fi - echo 'if [ -f $LOGDIR/update-$UPDATE.log ]; then' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' if [[ `grep "$TEXT" $LOGDIR/update-$UPDATE.log | grep -v "No files"` ]]; then' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' SENDUPDATE="YES"' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' fi' >> $TEMPFOLDER/update_$UPDATE.sh - echo 'fi' >> $TEMPFOLDER/update_$UPDATE.sh - if [ "$VARIABLE2" == "install" ]; then - echo 'SENDUPDATE="YES"' >> $TEMPFOLDER/update_$UPDATE.sh - fi - # Report back to Easy-WI - echo 'if [ "$SENDUPDATE" == "YES" ]; then' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$UPDATE | $BOMRM`' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' while [ "$CHECK" != "ok" -a "$I" -le "10" ]; do' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' if [ "$CHECK" == "" ]; then' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' I=11' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' else' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' sleep 30' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' I=$[I+1]' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$UPDATE | $BOMRM`' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' fi' >> $TEMPFOLDER/update_$UPDATE.sh - echo ' done' >> $TEMPFOLDER/update_$UPDATE.sh - echo 'fi' >> $TEMPFOLDER/update_$UPDATE.sh - fdlList $TEMPFOLDER/update_$UPDATE.sh $FDLFOLDER - echo 'find $HOMEFOLDER -type f -iname "wget-*" -delete' >> $TEMPFOLDER/update_$UPDATE.sh - echo 'cd' >> $TEMPFOLDER/update_$UPDATE.sh -cat >> $TEMPFOLDER/update_$UPDATE.sh << EOF -${IONICE}nice -n +19 find $HOMEFOLDER/masterserver/$UPDATE -type f \( -iname "srcds_*" -or -iname "hlds_*" -or -iname "*.run" -or -iname "*.sh" \) -print0 | xargs -0 chmod 750 -${IONICE}nice -n +19 find $HOMEFOLDER/masterserver/$UPDATE -type f ! -perm -750 ! -perm -755 -print0 | xargs -0 chmod 640 -${IONICE}nice -n +19 find $HOMEFOLDER/masterserver/$UPDATE -type d -print0 | xargs -0 chmod 750 -EOF - chmod +x $TEMPFOLDER/update_$UPDATE.sh - screen -d -m -S $UPDATE.update $TEMPFOLDER/update_$UPDATE.sh - echo "`date`: Update started for $UPDATE" >> $LOGDIR/update.log - fi -done -} - -function server_delete { -COUNT="`echo $VARIABLE2 | awk -F "_" '{ print $1 }'`" -COUNT=$[COUNT+1] -i=2 -while [ $i -le $COUNT ]; do - GAMENAME=`echo $VARIABLE2 | awk -F_ '{ print $'$i' }'` - if [ "$GAMENAME" != "" ]; then - screen -dmS $GAMENAME.delete rm -rf $HOMEFOLDER/masterserver/$GAMENAME $HOMEFOLDER/mastermaps/$GAMENAME $HOMEFOLDER/masteraddons/$GAMENAME - echo "`date`: Masterserver $GAMENAME deleted" >> $LOGDIR/update.log - fi - i=$[i+1] -done -echo "Server deleted" -} - -function add_user { -# adduser username ftpPassword homeDir (optional protected ftpPassword) -CONFIGUSERID=`grep CONFIGUSERID $HOMEFOLDER/conf/config.cfg 2> /dev/null | awk -F "=" '{print $2}' | tr -d '"'` -if [ "$CONFIGUSERID" == "" ]; then CONFIGUSERID=1000; fi -USER=`ls -la /var/run/screen | grep S-$VARIABLE2 | head -n 1 | awk '{print $3}'` -if [ $USER -eq $USER 2> /dev/null ]; then USERID=$USER; fi -USERGROUPD=`ls -l $VARIABLE0 | awk '{print $4}'` -if [ "$VARIABLE4" == "" ]; then VARIABLE4="/home"; fi -if [ "$USERID" != "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2} | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $USERID $VARIABLE2 2>/dev/null -else - USERID=`getent passwd | cut -f3 -d: | sort -un | awk 'BEGIN { id='${CONFIGUSERID}' } $1 == id { id++ } $1 > id { print id; exit }'` - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" == "" -a "`grep \"x:$USERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2} | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $USERID $VARIABLE2 2>/dev/null - else - while [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" != "" -o "`grep \"x:$USERID:\" /etc/passwd`" != "" ]; do - USERID=$[USERID+1] - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" == "" -a "`grep \"x:$USERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2} | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $USERID $VARIABLE2 2>/dev/null - fi - done - fi -fi -if [ "$VARIABLE5" != "" ]; then - PUSER=`ls -la /var/run/screen | grep S-$VARIABLE2-p | head -n 1 | awk '{print $3}'` - if [ $PUSER -eq $PUSER 2> /dev/null ]; then PUSERID=$PUSER; fi - if [ "$PUSERID" != "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE5'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2}/pserver | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $PUSERID $VARIABLE2-p - else - PUSERID=`getent passwd | cut -f3 -d: | sort -un | awk 'BEGIN { id='${CONFIGUSERID}' } $1 == id { id++ } $1 > id { print id; exit }'` - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" == "" -a "`grep \"x:$PUSERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2}/pserver | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $PUSERID $VARIABLE2-p - else - while [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" != "" -o "`grep \"x:$PUSERID:\" /etc/passwd`" != "" ]; do - PUSERID=$[PUSERID+1] - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" == "" -a "`grep \"x:$PUSERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d "`echo ${VARIABLE4}/${VARIABLE2}/pserver | sed 's/\/\//\//g'`" -g $USERGROUPD -s /bin/bash -u $PUSERID $VARIABLE2-p - fi - done - fi - fi -fi -} - -function add_customer { -CONFIGUSERID=`grep CONFIGUSERID $HOMEFOLDER/conf/config.cfg 2> /dev/null | awk -F "=" '{print $2}' | tr -d '"'` -if [ "$CONFIGUSERID" == "" ]; then CONFIGUSERID=1000; fi -USER=`ls -la /var/run/screen | grep S-$VARIABLE2 | head -n 1 | awk '{print $3}'` -if [ $USER -eq $USER 2> /dev/null ]; then USERID=$USER; fi -PUSER=`ls -la /var/run/screen | grep S-$VARIABLE2-p | head -n 1 | awk '{print $3}'` -if [ $PUSER -eq $PUSER 2> /dev/null ]; then PUSERID=$PUSER; fi -if [ "$USERID" != "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -g $VARIABLE4 -s /bin/bash -u $USERID $VARIABLE2 -else - USERID=`getent passwd | cut -f3 -d: | sort -un | awk 'BEGIN { id='${CONFIGUSERID}' } $1 == id { id++ } $1 > id { print id; exit }'` - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" == "" -a "`grep \"x:$USERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -g $VARIABLE4 -s /bin/bash -u $USERID $VARIABLE2 - else - while [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" != "" -o "`grep \"x:$USERID:\" /etc/passwd`" != "" ]; do - USERID=$[USERID+1] - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $USERID`" == "" -a "`grep \"x:$USERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -g $VARIABLE4 -s /bin/bash -u $USERID $VARIABLE2 - fi - done - fi -fi -if [ "$PUSERID" != "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE5'","Sa")'` -d /home/$VARIABLE2/pserver -g $VARIABLE4 -s /bin/bash -u $PUSERID $VARIABLE2-p -else - PUSERID=`getent passwd | cut -f3 -d: | sort -un | awk 'BEGIN { id='${CONFIGUSERID}' } $1 == id { id++ } $1 > id { print id; exit }'` - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" == "" -a "`grep \"x:$PUSERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d /home/$VARIABLE2/pserver -g $VARIABLE4 -s /bin/bash -u $PUSERID $VARIABLE2-p - else - while [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" != "" -o "`grep \"x:$PUSERID:\" /etc/passwd`" != "" ]; do - PUSERID=$[PUSERID+1] - if [ "`ls -la /var/run/screen | awk '{print $3}' | grep $PUSERID`" == "" -a "`grep \"x:$PUSERID:\" /etc/passwd`" == "" ]; then - sudo /usr/sbin/useradd -m -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` -d /home/$VARIABLE2/pserver -g $VARIABLE4 -s /bin/bash -u $PUSERID $VARIABLE2-p - fi - done - fi -fi -echo "user added" -echo "`date`: User $VARIABLE2 created" >> $LOGDIR/update.log -} - -function customerDelete { -echo "#!/bin/bash -rm -f $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -#${IONICE}nice -n +19 sudo /usr/sbin/deluser --remove-all-files ${VARIABLE2}-p -#${IONICE}nice -n +19 sudo /usr/sbin/deluser --remove-all-files ${VARIABLE2} -${IONICE}nice -n +19 sudo /usr/sbin/userdel -fr ${VARIABLE2}-p -${IONICE}nice -n +19 sudo /usr/sbin/userdel -fr ${VARIABLE2}" > $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -chmod +x $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -screen -d -m -S del-user-${VARIABLE2} $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -echo "`date`: User $VARIABLE2 deleted" >> $LOGDIR/update.log -} - -function user_single_delete { -if [ "`id ${VARIABLE2} 2>/dev/null`" != "" ]; then -echo "#!/bin/bash -rm -f $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -${IONICE}nice -n +19 sudo /usr/sbin/userdel -fr ${VARIABLE2}" > $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -chmod +x $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -screen -d -m -S del-user-${VARIABLE2} $HOMEFOLDER/temp/del-user-${VARIABLE2}.sh -echo "`date`: User $VARIABLE2 deleted" >> $LOGDIR/update.log -fi -} - -function del_customer_screen { - ps x | grep "SCREEN" | grep -v "grep" | awk '{print $1}' | while read PID; do - kill $PID - done - screen -wipe > /dev/null 2>&1 - pkill -u `whoami` -} - -function mod_customer { -if [ "$VARIABLE4" != "" ]; then sudo /usr/sbin/usermod -p `perl -e 'print crypt("'$VARIABLE4'","Sa")'` $VARIABLE2-p; fi -sudo /usr/sbin/usermod -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` $VARIABLE2 -echo "user edited" -echo "`date`: Userpassword for $VARIABLE2 edited" >> $LOGDIR/update.log -} - -function mod_user { -if [ "$VARIABLE4" != "" -a "$VARIABLE4" != "1" ]; then USERHOME=" -m -d `echo ${VARIABLE4}/${VARIABLE2} | sed 's/\/\//\//g'`"; else USERHOME=''; fi -sudo /usr/sbin/usermod -p `perl -e 'print crypt("'$VARIABLE3'","Sa")'` $USERHOME $VARIABLE2 -if [ "`id ${VARIABLE2}-p 2>/dev/null`" != "" -a "$USERHOME" != "" ]; then USERHOME="`echo ${USERHOME}/pserver | sed 's/\/\//\//g'`"; sudo /usr/sbin/usermod $USERHOME $VARIABLE2-p; fi -if [ "$VARIABLE5" != "" ]; then sudo /usr/sbin/usermod -p `perl -e 'print crypt("'$VARIABLE5'","Sa")'` $VARIABLE2-p; fi -echo "user edited" -echo "`date`: Userpassword for $VARIABLE2 edited" >> $LOGDIR/update.log -} - -function imagesymlinks { -echo "GAMENAME=$GAMENAME -if [ ! -d $SERVERDIR/$VARIABLE4/$GAMENAME ]; then - mkdir -p $SERVERDIR/$VARIABLE4/$GAMENAME -fi" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -if [ "$MODINSTALL" == "1" ]; then - echo "if [ -d $HOMEFOLDER/masterserver/$MODNAME -a \"$MODNAME\" != \"\" ]; then" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "cd $HOMEFOLDER/masterserver/$MODNAME" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'FDLFILEFOUND=(`find -mindepth 1 -type f -name "*.xml" -o -name "*.vdf" -o -name "*.cfg" -o -name "*.con" -o -name "*.conf" -o -name "*.config" -o -name "*.config" -o -name "*.ini" -o -name "*.gam" -o -name "*.txt" -o -name "*.log" -o -name "*.smx" -o -name "*.sp" -o -name "*.db" -o -name "*.lua" -o -name "*.props" -o -name "*.properties" -o -name "*.json" -o -name "*.example" | grep -v "$PATTERN"`)' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'for FILTEREDFILES in ${FDLFILEFOUND[@]}; do - FOLDERNAME=`dirname "$FILTEREDFILES"` - if ([[ `find "$FOLDERNAME" -maxdepth 0 -type d` ]] && [[ ! -d "$SERVERDIR/$VARIABLE4/$GAMENAME/$FOLDERNAME" ]]); then - mkdir -p "$SERVERDIR/$VARIABLE4/$GAMENAME/$FOLDERNAME" - fi - if [[ -f "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" ]]; then - find "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" -type l -delete - fi - if [[ ! `find "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" -type f` ]]; then - '"${IONICE}"'cp "$HOMEFOLDER/masterserver/$MODNAME/$FILTEREDFILES" "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" - fi -done -'"${IONICE}"'cp -sr $HOMEFOLDER/masterserver/$MODNAME/* $SERVERDIR/$VARIABLE4/$GAMENAME/ -fi' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -fi -echo "if [ -d $HOMEFOLDER/masterserver/$GAMENAME2 -a \"$GAMENAME2\" != \"\" ]; then" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -echo "cd $HOMEFOLDER/masterserver/$GAMENAME2" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -echo 'FDLFILEFOUND=(`find -mindepth 1 -type f -name "*.xml" -o -name "*.vdf" -o -name "*.cfg" -o -name "*.con" -o -name "*.conf" -o -name "*.config" -o -name "*.config" -o -name "*.ini" -o -name "*.gam" -o -name "*.txt" -o -name "*.log" -o -name "*.smx" -o -name "*.sp" -o -name "*.db" -o -name "*.lua" -o -name "*.props" -o -name "*.properties" -o -name "*.json" -o -name "*.example" | grep -v "$PATTERN"`)' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -echo 'for FILTEREDFILES in ${FDLFILEFOUND[@]}; do - FOLDERNAME=`dirname "$FILTEREDFILES"` - if ([[ `find "$FOLDERNAME" -maxdepth 0 -type d` ]] && [[ ! -d "$SERVERDIR/$VARIABLE4/$GAMENAME/$FOLDERNAME" ]]); then - mkdir -p "$SERVERDIR/$VARIABLE4/$GAMENAME/$FOLDERNAME" - fi - if [ -f "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" ]; then - find "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" -type l -delete - fi - if [ ! -f "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" ]; then - '"${IONICE}"'cp "$HOMEFOLDER/masterserver/$GAMENAME2/$FILTEREDFILES" "$SERVERDIR/$VARIABLE4/$GAMENAME/$FILTEREDFILES" - fi -done -'"${IONICE}"'cp -sr $HOMEFOLDER/masterserver/$GAMENAME2/* $SERVERDIR/$VARIABLE4/$GAMENAME/ -fi' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -} - -function remove_folders { -echo "if [ -d $SERVERDIR/$VARIABLE4/$GAMENAME ]; then ${IONICE}rm -rf $SERVERDIR/$VARIABLE4/$GAMENAME; fi" >> $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -if [ -f $LOGDIR/update.log ]; then echo "`date`: Server $VARIABLE4/$VARIABLE3 owned by user $VARIABLE2 deleted" >> $LOGDIR/update.log; fi -} - -function del_customer_server { -USERHOME='/home' -if [ "$VARIABLE6" != "" ]; then USERHOME=$VARIABLE6; fi -if [ "$VARIABLE5" == "protected" ]; then - USERVAR=`echo $VARIABLE2 | awk -F "-" '{print $2}'` - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - if [ "$USERVAR" != "" -a "$USERVAR" != "p" ]; then - VARIABLE2="$VARIABLE2-$USERVAR" - fi - SERVERDIR=$USERHOME/$VARIABLE2/pserver -else - SERVERDIR=$USERHOME/$VARIABLE2/server -fi -SERVERDIR=`echo $SERVERDIR | sed 's/\/\//\//g'` -echo "#!/bin/bash - -HOMEFOLDER=$HOMEFOLDER -rm -f $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -VARIABLE2=$VARIABLE2 -VARIABLE4=$VARIABLE4 -SERVERDIR=$SERVERDIR" > $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -COUNT=`echo $VARIABLE3 | awk -F_ '{ print $1 }'` -COUNT=$[COUNT+1] -i=2 -while [ $i -le $COUNT ]; do - GAMENAME=`echo $VARIABLE3 | awk -F "_" '{ print $'$i' }'` - GAMENAME2=$GAMENAME - if [ "$GAMENAME" != "" ]; then - if [ "$VARIABLE5" == "" ]; then - TEMPLATE=4 - elif [ "$VARIABLE5" != "protected" -a "$VARIABLE5" != "unprotected" ]; then - TEMP=(`echo $VARIABLE5 | sed -e 's/-/ /g'`) - TEMPLATE=${TEMP[$[i-2]]} - else - TEMPLATE=1 - fi - if [ "$TEMPLATE" == 1 -o "$TEMPLATE" == 4 ]; then remove_folders; fi - if [ "$VARIABLE5" != "protected" ]; then - if [ "$TEMPLATE" == 2 -o "$TEMPLATE" == 4 -o "$VARIABLE5" == "unprotected" ]; then - GAMENAME="${GAMENAME2}-2" - echo "GAMENAME=$GAMENAME" >> $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh - remove_folders - fi - if [ "$TEMPLATE" == 3 -o "$TEMPLATE" == 4 -o "$VARIABLE5" == "unprotected" ]; then - GAMENAME="${GAMENAME2}-3" - echo "GAMENAME=$GAMENAME" >> $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh - remove_folders - fi - fi - fi - i=$[i+1] -done -echo 'if [ -d "$SERVERDIR/$VARIABLE4" -a "`ls $SERVERDIR/$VARIABLE4 | wc -l`" == "0" ]; then' >> $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -echo " ${IONICE}rm -rf $SERVERDIR/$VARIABLE4 -fi" >> $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -chmod +x $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -screen -dmS del-$VARIABLE2-$VARIABLE4 $HOMEFOLDER/temp/del-$VARIABLE2-$VARIABLE4.sh -echo "server deleted" -} - -function add_customer_server { -USERHOME='/home' -if [ "$VARIABLE6" != "" ]; then USERHOME=$VARIABLE6; fi -if [ "$VARIABLE5" == "protected" ]; then - USERVAR=`echo $VARIABLE2 | awk -F "-" '{print $2}'` - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - if [ "$USERVAR" != "" -a "$USERVAR" != "p" ]; then - VARIABLE2="$VARIABLE2-$USERVAR" - fi - SERVERDIR=$USERHOME/$VARIABLE2/pserver -else - SERVERDIR=$USERHOME/$VARIABLE2/server -fi -SERVERDIR=`echo $SERVERDIR | sed 's/\/\//\//g'` -if [[ ! `screen -ls | grep "add-$VARIABLE2-$VARIABLE4"` ]]; then -if [ "$VARIABLE1" != "migrateserver" ]; then -echo "#!/bin/bash - -HOMEFOLDER=$HOMEFOLDER -rm -f $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -VARIABLE2=$VARIABLE2 -VARIABLE4=$VARIABLE4 -SERVERDIR=$SERVERDIR -PATTERN='valve\|overviews/\|scripts/\|media/\|particles/\|gameinfo.txt\|steam.inf\|/sound/\|steam_appid.txt\|/hl2/\|/overviews/\|/resource/\|/sprites/'" > $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -echo 'while [[ `screen -ls | grep "del-$VARIABLE2-$VARIABLE4"` ]]; do - sleep 1 -done' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -fi - -COUNT=`echo $VARIABLE3 | awk -F_ '{ print $1 }'` -COUNT=$[COUNT+1] -i=2 -while [ $i -le $COUNT ]; do - MODNAME="" - GAMENAME=`echo $VARIABLE3 | awk -F "_" '{print $'$i'}'` - if [ "$GAMENAME" != "" ]; then - if [ "$VARIABLE5" == "" ]; then - TEMPLATE=4 - elif [ "$VARIABLE5" != "protected" ]; then - TEMP=(`echo $VARIABLE5 | sed -e 's/-/ /g'`) - TEMPLATE=${TEMP[$[i-2]]} - else - TEMPLATE=1 - fi - MODNAME=`echo $GAMENAME | awk -F "." '{print $2}'` - FILEFOUND="" - FDLFILEFOUND="" - if [ "$MODNAME" != "" ]; then - MODINSTALL="1" - GAMENAME=`echo $GAMENAME | awk -F "." '{print $1}'` - GAMENAME2=$GAMENAME - else - GAMENAME2=$GAMENAME - fi - echo "GAMENAME2=$GAMENAME" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - if [ "$TEMPLATE" == 1 -o "$TEMPLATE" == 4 ]; then - imagesymlinks - fi - if [ "$VARIABLE5" != "protected" ]; then - if [ "$TEMPLATE" == 2 -o "$TEMPLATE" == 4 ]; then - GAMENAME="${GAMENAME2}-2" - imagesymlinks - fi - if [ "$TEMPLATE" == 3 -o "$TEMPLATE" == 4 ]; then - GAMENAME="${GAMENAME2}-3" - imagesymlinks - fi - fi - if [ "$TEMPLATE" == 4 ]; then - echo "${IONICE}nice -n +19 find $SERVERDIR/$VARIABLE4/ -type d -print0 | xargs -0 chmod 700" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "${IONICE}nice -n +19 find $SERVERDIR/$VARIABLE4/ -type f -print0 | xargs -0 chmod 600" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "${IONICE}nice -n +19 find -L $SERVERDIR/$VARIABLE4/ -type l -print0 | xargs -0 -rf" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - else - echo "${IONICE}nice -n +19 find $SERVERDIR/$VARIABLE4/$GAMENAME/ -type d -print0 | xargs -0 chmod 700" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "${IONICE}nice -n +19 find $SERVERDIR/$VARIABLE4/$GAMENAME/ -type f -print0 | xargs -0 chmod 600" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "${IONICE}nice -n +19 find -L $SERVERDIR/$VARIABLE4/$GAMENAME/ -type l -print0 | xargs -0 rm -f" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - fi - echo 'echo "`date`: Server $VARIABLE4/$GAMENAME2 for user $VARIABLE2 created" >> '"$LOGDIR/update.log" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - fi - i=$[i+1] -done -if [ "$VARIABLE1" != "migrateserver" ]; then - chmod +x $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - screen -d -m -S add-$VARIABLE2-$VARIABLE4 $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -fi -fi -} - -function reinst_customer_server { - del_customer_server - add_customer_server -} - -function migration { - FTPUSER=$VARIABLE6 - VARIABLE6=$VARIABLE10 - CUTDIRS=${VARIABLE8/ftps:\/\//} - CUTDIRS=${CUTDIRS/ftp:\/\//} - CUTDIRS=${CUTDIRS//\/\//\/} - CUTDIRS=(${CUTDIRS//\// }) - CUTDIRS=${#CUTDIRS[@]} - CUTDIRS=$[CUTDIRS-1] - USERHOME='/home' - if [ "$VARIABLE10" != "" ]; then USERHOME=$VARIABLE10; fi - SERVERDIR=`echo $USERHOME/$VARIABLE2/server | sed 's/\/\//\//g'` -echo "#!/bin/bash - -HOMEFOLDER=$HOMEFOLDER -rm -f $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -VARIABLE2=$VARIABLE2 -VARIABLE4=$VARIABLE4 -VARIABLE9=$VARIABLE9 -SERVERDIR=$SERVERDIR -PATTERN='valve\|overviews/\|scripts/\|media/\|particles/\|gameinfo.txt\|steam.inf\|/sound/\|steam_appid.txt\|/hl2/\|/overviews/\|/resource/\|/sprites/'" > $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'while [[ `screen -ls | grep "del-$VARIABLE2-$VARIABLE4"` ]]; do sleep 5; done' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - if [ "$VARIABLE5" == "" -o "$VARIABLE5" == "1" ]; then - GSTEMPLATE=`echo $VARIABLE3 | awk -F "_" '{ print $2 }'` - else - GSTEMPLATE=`echo $VARIABLE3 | awk -F "_" '{ print $2 }'`"-$VARIABLE5" - fi - echo "GSTEMPLATE=$GSTEMPLATE" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - add_customer_server - echo 'if [ ! -d "$SERVERDIR/$VARIABLE4/$GSTEMPLATE/" ]; then mkdir -p "$SERVERDIR/$VARIABLE4/$GSTEMPLATE/"; fi' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'cd $SERVERDIR/$VARIABLE4/$GSTEMPLATE/' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'VARIABLE9=`echo $VARIABLE9 | tr -d '"'"'/'"'"'`' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'MODFOLDER=`find -mindepth 1 -maxdepth 3 -type d -name "$VARIABLE9" | head -n 1`' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'if [ "$MODFOLDER" != "" -a "$VARIABLE9" != "none" ]; then cd $MODFOLDER; fi' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo 'find $SERVERDIR/$VARIABLE4/$GSTEMPLATE/ -type f -print0 | xargs -0 rm -f' >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - echo "wget -q -r -l inf -nc -nH --limit-rate=4096K --retr-symlinks --ftp-user=$FTPUSER --ftp-password=$VARIABLE7 --cut-dirs=$CUTDIRS --no-check-certificate $VARIABLE8" >> $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - add_customer_server - chmod +x $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh - screen -d -m -S add-$VARIABLE2-$VARIABLE4 $HOMEFOLDER/temp/add-$VARIABLE2-$VARIABLE4.sh -} - -function port_move { -cd /home/$VARIABLE2/server -mv $VARIABLE3 $VARIABLE4 -} - -function move_server { -if [ "$VARIABLE5" == "" ]; then VARIABLE5='/home'; fi -echo "#!/bin/bash - -VARIABLE2=$VARIABLE2 -VARIABLE3=$VARIABLE3 -VARIABLE4=$VARIABLE4 -VARIABLE5=$VARIABLE5 -rm -f $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh" > $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -echo 'while [[ `screen -ls | grep "del-$VARIABLE2-$VARIABLE3"` ]]; do - sleep 1 -done' >> $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -echo 'cd $VARIABLE5/$VARIABLE2/server' >> $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -echo 'if [ -d "$VARIABLE4" ]; then rm -rf "$VARIABLE4"; fi' >> $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -echo 'mv $VARIABLE3 $VARIABLE4' >> $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -chmod +x $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -screen -dmS del-$VARIABLE2-$VARIABLE4 $HOMEFOLDER/temp/move-$VARIABLE2-$VARIABLE4.sh -} - -function map_list { - if [[ "$VARIABLE1" == "addaddon" ]]; then - GAMESHORTEN=`echo $GAMEDIR | awk -F '/' '{print $6}'` - cd $HOMEFOLDER/masterserver/$GAMESHORTEN - if [ "`find -maxdepth 2 -name srcds_run`" != "" ]; then - MAPCFGS="1" - MAPTYPE="bsp" - elif [ "`find -maxdepth 2 -name hlds_run`" != "" ]; then - MAPTYPE="bsp" - elif [ "`find -maxdepth 1 -name ucc-bin`" != "" ]; then - MAPTYPE="rom" - fi - cd $ADDONFOLDER - else - if [ "`find -maxdepth 2 -name srcds_run`" != "" ]; then - MAPCFGS="1" - MAPTYPE="bsp" - elif [ "`find -maxdepth 2 -name hlds_run`" != "" ]; then - MAPTYPE="bsp" - elif [ "`find -maxdepth 1 -name ucc-bin`" != "" ]; then - MAPTYPE="rom" - cd .. - fi - fi - if [ -n $MAPTYPE ]; then - if [[ "$VARIABLE1" == "addaddon" ]]; then - if [ "$MAPTYPE" == "bsp" ]; then - cd `find -maxdepth 2 -name maps | head -n 1` - elif [ "$MAPTYPE" == "rom" ]; then - cd `find -maxdepth 2 -name maps | head -n 1` - fi - ls *.$MAPTYPE | grep -v "test_hardware\|test_speakers" | awk -F "." '{print $1}' > $GAMEDIR/$VARIABLE3.txt - cd $ADDONFOLDER - else - if [ "`find -maxdepth 2 -name steam.inf | awk -F '/' '{print $2}' | grep -v 'valve' | wc -l`" == "1" ]; then - cd `find -maxdepth 2 -name steam.inf | awk -F '/' '{print $2}' | grep -v 'valve'` - elif [ "`find -maxdepth 2 -name steam.inf | awk -F '/' '{print $2}' | grep -v 'valve\|cstrike' | wc -l`" == "1" ]; then - cd `find -maxdepth 2 -name steam.inf | awk -F '/' '{print $2}' | grep -v 'valve\|cstrike'` - elif [[ `find -name da2` ]]; then - cd `find -name da2` - fi - if [ -f maplist.txt ]; then rm -f maplist.txt; fi - if [ "$MAPTYPE" == "bsp" ]; then - cd `find -maxdepth 3 -type d -name "maps" | head -n 1` - elif [ "$MAPTYPE" == "rom" ]; then - cd `find -maxdepth 3 -type d -name "maps" | head -n 1` - fi - ls *.$MAPTYPE 2> /dev/null | grep -v "test_hardware\|test_speakers" | awk -F "." '{print $1}' | while read MAPNAME; do - echo $MAPNAME >> ../maplist.txt - done - fi - fi -} - -function run_backup { - if [ "$SHORTEN" != "" ]; then - echo "VARIABLE2=$VARIABLE2 -SHORTEN=$SHORTEN -find $BACKUPDIR/ -maxdepth 1 -type f -name \"$VARIABLE2-$SHORTEN*.tar.bz2\" -delete" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'if [ -d $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN ]; then' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "cd $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "${IONICE}"'nice -n +19 tar cfj $BACKUPDIR/$VARIABLE2-$SHORTEN.tar.bz2 .' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'fi' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'if [ -d $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN-2 ]; then' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "cd $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN-2" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "${IONICE}"'nice -n +19 tar cfj $BACKUPDIR/$VARIABLE2-$SHORTEN-2.tar.bz2 .' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'fi' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'if [ -d $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN-3 ]; then' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "cd $USERHOME/$USERNAME/server/$VARIABLE2/$SHORTEN-3" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "${IONICE}"'nice -n +19 tar cfj $BACKUPDIR/$VARIABLE2-$SHORTEN-3.tar.bz2 .' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo 'fi' >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - if [ "$VARIABLE5" != "" -a "$VARIABLE5" != "none" ]; then - echo "wput -q --limit-rate=$FTPUPLOADLIMIT --basename=$USERHOME/$USERNAME/backup/ \"$BACKUPDIR/$VARIABLE2-$SHORTEN.tar.bz2\" \"$VARIABLE5\"" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "wput -q --limit-rate=$FTPUPLOADLIMIT --basename=$USERHOME/$USERNAME/backup/ \"$BACKUPDIR/$VARIABLE2-$SHORTEN-2.tar.bz2\" \"$VARIABLE5\"" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - echo "wput -q --limit-rate=$FTPUPLOADLIMIT --basename=$USERHOME/$USERNAME/backup/ \"$BACKUPDIR/$VARIABLE2-$SHORTEN-3.tar.bz2\" \"$VARIABLE5\"" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - fi - fi -} - -function backup_servers { - USERHOME='/home' - if [ "$VARIABLE6" != "" ]; then USERHOME=$VARIABLE6; fi - USERNAME=`id -un` - BACKUPDIR="$USERHOME/$USERNAME/backup" - echo "#!/bin/bash - -rm -f $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh -BACKUPDIR=$BACKUPDIR -USERNAME=$USERNAME -USERHOME=$USERHOME" > $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - if [ ! -d $BACKUPDIR ]; then - mkdir -p $BACKUPDIR - fi - for SHORTEN in $VARIABLE3; do - SCREENNAME="backup-$VARIABLE2-$SHORTEN" - if [ "`screen -ls | grep \"$SCREENNAME\"`" == "" ]; then - run_backup - fi - done - IP=`echo $VARIABLE2 | awk -F '_' '{print $1}'` - PORT=`echo $VARIABLE2 | awk -F '_' '{print $2}'` - if [ "$PORT" == "" ]; then - QUERY="id=$VARIABLE2" - else - QUERY="id=$PORT\\&ip=$IP" - fi - VARIABLE4=`echo $VARIABLE4 | tr -d ' '` - echo "wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=bu\\&shorten=$USERNAME\\&$QUERY" >> $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - chmod +x $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh - screen -dmS $SCREENNAME $HOMEFOLDER/temp/backup-$VARIABLE2-$USERNAME.sh -} - -function restore_backup { - USERHOME='/home' - if [ "$VARIABLE6" != "" ]; then USERHOME=$VARIABLE6; fi - USERNAME=`id -un` - IP=`echo $VARIABLE2 | awk -F '_' '{print $1}'` - PORT=`echo $VARIABLE2 | awk -F '_' '{print $2}'` - if [ "$PORT" == "" ]; then - QUERY="id=$VARIABLE2" - else - QUERY="id=$PORT\\&ip=$IP" - fi - VARIABLE4=`echo $VARIABLE4 | tr -d ' '` - SCREENNAME=restorerestore-$VARIABLE2-$VARIABLE3 - if ([[ ! `screen -ls | grep "$SCREENNAME"` ]] && [[ ! `screen -ls | grep "backup-$VARIABLE2-$SHORTEN"` ]]); then - echo "#!/bin/bash" > $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "rm -f $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "USERHOME=$USERHOME" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - if [ "$VARIABLE5" != "" -a "$VARIABLE5" != "none" ]; then - echo "if [ ! -f $USERHOME/$USERNAME/backup/ ]; then mkdir -p $USERHOME/$USERNAME/backup/; fi" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "cd $USERHOME/$USERNAME/backup/" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "mv $USERHOME/$USERNAME/backup/$VARIABLE2-$VARIABLE3.tar.bz2 $USERHOME/$USERNAME/backup/$VARIABLE2-${VARIABLE3}_old.tar.bz2" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "wget -q --timeout=10 --no-check-certificate $VARIABLE5/$VARIABLE2-$VARIABLE3.tar.bz2" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "if [ -f $USERHOME/$USERNAME/backup/$VARIABLE2-$VARIABLE3.tar.bz2 ]; then" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo " rm -f $USERHOME/$USERNAME/backup/$VARIABLE2-${VARIABLE3}_old.tar.bz2" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "else" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo " mv $USERHOME/$USERNAME/backup/$VARIABLE2-${VARIABLE3}_old.tar.bz2 $USERHOME/$USERNAME/backup/$VARIABLE2-$VARIABLE3.tar.bz2" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "fi" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - fi - echo "if [ -f $USERHOME/$USERNAME/backup/$VARIABLE2-$VARIABLE3.tar.bz2 ]; then" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "rm -rf $USERHOME/$USERNAME/server/$VARIABLE2/$VARIABLE3/*" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "${IONICE}nice -n +19 tar -C $USERHOME/$USERNAME/server/$VARIABLE2/$VARIABLE3 -xjf $USERHOME/$USERNAME/backup/$VARIABLE2-$VARIABLE3.tar.bz2" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "wget -q --no-check-certificate -O - $VARIABLE4/get_password.php?w=rb\\&shorten=$USERNAME\\&$QUERY" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - echo "fi" >> $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - chmod +x $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - screen -dmS $SCREENNAME $HOMEFOLDER/temp/restore-$VARIABLE2-$VARIABLE3-$USERNAME.sh - fi -} - -function match_addons { -USERHOME='/home' -if [ "$VARIABLE5" != "" ]; then USERHOME=$VARIABLE5; fi -VARIABLE5='' -SERVERDIR=`echo "$USERHOME/$VARIABLE2/server/$VARIABLE3" | sed 's/\/\//\//g'` -if [ -d $SERVERDIR/*/addons/sourcemod ]; then - for ADDONLIST in $VARIABLE4; do - if [ -d $HOMEFOLDER/masteraddons/$ADDONLIST/addons/sourcemod ]; then - cd $HOMEFOLDER/masteraddons/$ADDONLIST/addons/sourcemod - find gamedata plugins scripting -mindepth 1 \( -iname "*.smx" \) 2> /dev/null | while read FILE; do - FILENAME=`basename $FILE` - find $SERVERDIR/*/addons/sourcemod/ -mindepth 2 -name "$FILENAME" | while read FOUNDFILE; do - if [ "`stat -c %Y $FILE`" -gt "`stat -c %Y $FOUNDFILE`" 2> /dev/null ]; then - cp $FILE $FOUNDFILE - fi - done - done - fi - done -fi -if [ -d $SERVERDIR/*/cfg/mani_admin_plugin ]; then - for ADDONLIST in $VARIABLE4; do - if [ -d $HOMEFOLDER/masteraddons/$ADDONLIST/cfg/mani_admin_plugin ]; then - find $HOMEFOLDER/masteraddons/$ADDONLIST/cfg/mani_admin_plugin -maxdepth 1 -name "gametypes.txt" 2> /dev/null | while read FILE; do - FILENAME=`basename $FILE` - find $SERVERDIR/*/cfg/mani_admin_plugin -maxdepth 1 -name "gametypes.txt" | while read FOUNDFILE; do - if [ "`stat -c %Y $FILE`" -gt "`stat -c %Y $FOUNDFILE`" 2> /dev/null ]; then - cp $FILE $FOUNDFILE - fi - done - done - fi - done -fi -MATCHADDONS=1 -ADDONS=$VARIABLE4 -VARIABLE4="$VARIABLE2/server/$VARIABLE3" -VARIABLE2="tool" -for VARIABLE3 in $ADDONS; do - if [ "$VARIABLE3" != "" -a -d $HOMEFOLDER/masteraddons/$VARIABLE3 ]; then - add_addon - fi -done -} - -function match_maps { -USERHOME='/home' -if [ "$VARIABLE5" != "" ]; then USERHOME=$VARIABLE5; fi -VARIABLE5='' -SERVERDIR=`echo "$USERHOME/$VARIABLE2/server/$VARIABLE3" | sed 's/\/\//\//g'` -MATCHADDONS=1 -MAPS=$VARIABLE4 -VARIABLE4="$VARIABLE2/server/$VARIABLE3" -VARIABLE2="map" -for VARIABLE3 in $MAPS; do - if [ "$VARIABLE3" != "" -a -d $HOMEFOLDER/mastermaps/$VARIABLE3 ]; then - add_addon - fi -done -} - -function server_start { -USERHOME='/home' -if [ "$VARIABLE8" != "" ]; then USERHOME=$VARIABLE8; fi -if [ -z $SERVERDIR ]; then - if [ "$VARIABLE5" == "protected" ]; then - if [[ "`echo $VARIABLE2 | awk -F "-" '{print $2}'`" == "p" ]]; then - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - elif [[ "`echo $VARIABLE2 | awk -F "-" '{print $2}'`" == "" ]]; then - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - else - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1"-"$2}'` - fi - SERVERDIR=$USERHOME/$VARIABLE2/pserver/$VARIABLE3 - else - SERVERDIR=$USERHOME/$VARIABLE2/server/$VARIABLE3 - fi -fi -SERVERDIR=`echo $SERVERDIR | sed 's/\/\//\//g'` -SCREENNAME="`echo $SERVERDIR | awk -F '/' '{print $5}'`" -FOLDERCHECK=`readlink -f $VARIABLE0` -if [[ ! `ps x | grep "start-${VARIABLE2}-${SCREENNAME}.sh" | grep -v grep` ]]; then -if [ ! -d $SERVERDIR ]; then - mkdir -p $SERVERDIR -fi -screen -wipe > /dev/null 2>&1 -SYNCGSPATH=`echo $SERVERDIR | awk -F '/' '{print $5}'` -SYNCGSFOLDER=`echo $SERVERDIR | awk -F '/' '{print $6}' | awk -F '-' '{print $1}'` -if [ "$VARIABLE5" != "protected" ]; then -GAMES=`ls $USERHOME/$VARIABLE2/server/$SYNCGSPATH | grep $SYNCGSFOLDER | egrep -v '\-2|\-3'` -else -GAMES=`ls $USERHOME/$VARIABLE2/pserver/$SYNCGSPATH | grep $SYNCGSFOLDER | egrep -v '\-2|\-3'` -fi -I=0 -GAMESTRING='' -for GAME in $GAMES; do - GAMESTRING="${GAMESTRING}_${GAME}" - I=$[I+1] -done -GAMESTRING="${I}${GAMESTRING}" -if [ "$VARIABLE5" != "protected" ]; then - CLEANFILE=$HOMEFOLDER/temp/cleanup-${VARIABLE2}-${SCREENNAME}.sh - STARTFILE=$HOMEFOLDER/temp/start-${VARIABLE2}-${SCREENNAME}.sh - CLEANUPDIR="$USERHOME/$VARIABLE2/server/" -else - CLEANFILE=$HOMEFOLDER/temp/cleanup-${VARIABLE2}-p-${SCREENNAME}.sh - STARTFILE=$HOMEFOLDER/temp/start-${VARIABLE2}-p-${SCREENNAME}.sh - CLEANUPDIR="$USERHOME/$VARIABLE2/pserver/" -fi -CLEANUPDIR=`echo $CLEANUPDIR | sed 's/\/\//\//g'` -cd $SERVERDIR -DONOTTOUCH='*/bin/*.so bin/*.so */cfg/valve.rc srcds_* hlds_* *.sh *.run' -for ISFILE in $DONOTTOUCH; do - find $ISFILE -maxdepth 1 -type f 2> /dev/null | while read BADFILE; do - MASTERGAME=`echo $SERVERDIR | awk -F '/' '{print $6}' | awk -F '-' '{print $1}'` - MASTERGAMEFOLDER=`echo $SERVERDIR | awk -F '/' '{print $7"/"$8}' | sed 's/\/\//\//g' | sed 's/\/\//\//g'` - MASTERPATH=`echo "$HOMEFOLDER/masterserver/$MASTERGAME/$MASTERGAMEFOLDER/$BADFILE" | sed 's/\/\//\//g'` - BADFILEPATH=`echo "$SERVERDIR/$BADFILE" | sed 's/\/\//\//g'` - chmod 666 $BADFILE - rm -f $BADFILE - if [ -f $BADFILE ]; then - exit 0 - fi - ln -s $MASTERPATH $BADFILEPATH - done - find $ISFILE -maxdepth 1 -type l 2> /dev/null | while read BADFILE; do - MASTERGAME=`echo $SERVERDIR | awk -F '/' '{print $6}' | awk -F '-' '{print $1}'` - MASTERGAMEFOLDER=`echo $SERVERDIR | awk -F '/' '{print $7"/"$8}' | sed 's/\/\//\//g' | sed 's/\/\//\//g'` - MASTERPATH=`echo "$HOMEFOLDER/masterserver/$MASTERGAME/$MASTERGAMEFOLDER/$BADFILE" | sed 's/\/\//\//g'` - BADFILEPATH=`echo "$SERVERDIR/$BADFILE" | sed 's/\/\//\//g'` - if [ "`ls -la $BADFILE | awk '{print $11}'`" != "$MASTERPATH" ]; then - rm -f $BADFILE - if [ -f $BADFILE ]; then - exit 0 - fi - ln -s $MASTERPATH $BADFILEPATH - fi - done -done -if [ "`screen -ls | grep '$SCREENNAME.'`" != "" ]; then - STARTED=no -else - if [ -d $SERVERDIR ]; then - map_list - cd $SERVERDIR - if [ "$VARIABLE7" != "" -a "$VARIABLE7" != "none" ]; then - TASKSET="taskset -c $VARIABLE7 " - else - TASKSET='' - fi - LOGTIME=`grep LOGTIME $HOMEFOLDER/conf/config.cfg | awk -F "=" '{print $2}' | tr -d '"'` - DEMOTIME=`grep DEMOTIME $HOMEFOLDER/conf/config.cfg | awk -F "=" '{print $2}' | tr -d '"'` - ZTMPTIME=`grep ZTMPTIME $HOMEFOLDER/conf/config.cfg | awk -F "=" '{print $2}' | tr -d '"'` - BADTIME=`grep BADTIME $HOMEFOLDER/conf/config.cfg | awk -F "=" '{print $2}' | tr -d '"'` - BADFILES=`grep BADFILES $HOMEFOLDER/conf/config.cfg | awk -F "=" '{print $2}' | tr -d '"' | sed 's/, / /g' | sed 's/,/ /g'` - if [ ! `echo "$LOGTIME" | grep -E "^[0-9]+$"` ]; then - LOGTIME="-mtime +7" - else - if [ "$LOGTIME" == "0" ]; then - LOGTIME="" - else - LOGTIME="-mtime +$LOGTIME" - fi - fi - if [ ! `echo "$DEMOTIME" | grep -E "^[0-9]+$"` ]; then - DEMOTIME="-mtime +7" - else - if [ "$DEMOTIME" == "0" ]; then - DEMOTIME="" - else - DEMOTIME="-mtime +$DEMOTIME" - fi - fi - if [ ! `echo "$ZTMPTIME" | grep -E "^[0-9]+$"` ]; then - ZTMPTIME="-mtime +7" - else - if [ "$ZTMPTIME" == "0" ]; then - ZTMPTIME="" - else - ZTMPTIME="-mtime +$ZTMPTIME" - fi - fi - if [ ! `echo "$BADTIME" | grep -E "^[0-9]+$"` ]; then - BADTIME="-mtime +7" - else - if [ "$BADTIME" == "0" ]; then - BADTIME="" - else - BADTIME="-mtime +$BADTIME" - fi - fi - if [ ! -f $STARTFILE ]; then - echo '#!/bin/bash' > $STARTFILE - echo "rm -f $STARTFILE" >> $STARTFILE - echo 'while [ "`ps x | grep '"'add-${VARIABLE2}'"' | grep -v grep`" != "" ]; do' >> $STARTFILE - echo 'sleep 0.5' >> $STARTFILE - echo 'done' >> $STARTFILE - fi - echo "cd ${SERVERDIR}" >> $STARTFILE - for FILE in $BADFILES; do - echo "find $CLEANUPDIR -type f -name \"*.$FILE\" $BADTIME -delete" >> $STARTFILE - done - echo "${IONICE}find -L $CLEANUPDIR -type l -delete" >> $STARTFILE - echo "${IONICE}find $CLEANUPDIR -type f -name '*.log' $LOGTIME -delete" >> $STARTFILE - echo "${IONICE}find $CLEANUPDIR -type f -name '*.dem' $DEMOTIME -delete" >> $STARTFILE - echo "${IONICE}find $CLEANUPDIR -type f -name '*.ztmp' $ZTMPTIME -delete" >> $STARTFILE - if [ "$VARIABLE5" != "protected" ]; then - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/ -maxdepth 1 \( -type f -or -type l \) ! \( -name \".bashrc\" -or -name \".bash_history\" -or -name \".profile\" -or -name \".bash_logout\" \) -delete" >> $STARTFILE - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/ -mindepth 2 -maxdepth 3 \( -type f -or -type l \) ! -name \"*.bz2\" -delete" >> $STARTFILE - echo "${IONICE}nice -n +19 find $DATADIR -type f -user `whoami` ! -name \"*.bz2\" -delete" >> $STARTFILE - fi - # Steampipe Fix Start - echo 'if [ -d "tf" -o -d "dod" -o -d "hl2mp" -o -d "cstrike" ]; then' >> $STARTFILE - echo 'if [ "`find orangebox/ css/ -type f 2> /dev/null | wc -l`" == "0" ]; then rm -rf orangebox/ css/ 2> /dev/null; fi' >> $STARTFILE - echo 'find orangebox/ css/ -mindepth 1 -maxdepth 1 -type d -name tf -o -name dod -o -name hl2mp -o -name cstrike 2> /dev/null | while read olddir; do' >> $STARTFILE - echo 'find $olddir -type f | while read oldfile; do' >> $STARTFILE - echo 'file=${oldfile/orangebox\//}' >> $STARTFILE - echo 'file=${file/css\//}' >> $STARTFILE - echo 'dir=`dirname "$file"`' >> $STARTFILE - echo 'if [ ! -d $dir ]; then mkdir -p $dir; fi' >> $STARTFILE - echo 'if [ ! -f "$file" ]; then mv "$oldfile" "$file"; fi' >> $STARTFILE - echo 'done' >> $STARTFILE - echo 'done' >> $STARTFILE - echo 'if [ "`find orangebox/ css/ -type f 2> /dev/null | wc -l`" == "0" ]; then rm -rf orangebox/ css/ 2> /dev/null; fi' >> $STARTFILE - echo 'fi' >> $STARTFILE - # Steampipe Fix Ende - echo "if [ -f screenlog.0 ]; then rm -f screenlog.0; fi" >> $STARTFILE - echo "${TASKSET} screen -A -m -d -L -S $SCREENNAME $VARIABLE4" >> $STARTFILE - chmod +x $STARTFILE - $STARTFILE > /dev/null 2>&1 & - STARTED=yes - else - STARTED=no - fi -fi -if [ -f $LOGDIR/server.log ]; then - if [ "$STARTED" == "yes" ]; then - echo "`date`: User started $VARIABLE2: $VARIABLE4" >> $LOGDIR/server.log - else - echo "`date`: Starting server $VARIABLE2 for user $VARIABLE2 failed" >> $LOGDIR/server.log - fi -fi -fi -} - -function server_stop { -USERHOME='/home' -if [ "$VARIABLE8" != "" -a "$VARIABLE1" == "grestart" ]; then - USERHOME=$VARIABLE8 -elif [ "$VARIABLE6" != "" -a "$VARIABLE1" != "grestart" ]; then - USERHOME=$VARIABLE6 -fi -if [ "$VARIABLE5" == "protected" ]; then - if [[ "`echo $VARIABLE2 | awk -F "-" '{print $2}'`" == "p" ]]; then - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - elif [[ "`echo $VARIABLE2 | awk -F "-" '{print $2}'`" == "" ]]; then - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1}'` - else - VARIABLE2=`echo $VARIABLE2 | awk -F "-" '{print $1"-"$2}'` - fi - SERVERDIR=$USERHOME/$VARIABLE2/pserver/$VARIABLE3 -else - SERVERDIR=$USERHOME/$VARIABLE2/server/$VARIABLE3 -fi -SERVERDIR=`echo $SERVERDIR | sed 's/\/\//\//g'` -SCREENNAME="`echo $SERVERDIR | awk -F '/' '{print $5}'`" -if [ "$VARIABLE5" != "protected" ]; then - STARTFILE=$HOMEFOLDER/temp/start-${VARIABLE2}-${SCREENNAME}.sh -else - STARTFILE=$HOMEFOLDER/temp/start-${VARIABLE2}-p-${SCREENNAME}.sh -fi -if [ "$VARIABLE1" == "grestart" ]; then - echo '#!/bin/bash' > $STARTFILE - echo "rm -f $STARTFILE" >> $STARTFILE - echo "SCREENNAME=$SCREENNAME" >> $STARTFILE - echo 'while [ "`ps x | egrep '"'add-${VARIABLE2}|del-${VARIABLE2}|move-${VARIABLE2}'"' | grep -v grep`" != "" ]; do' >> $STARTFILE - echo 'sleep 0.5' >> $STARTFILE - echo 'done' >> $STARTFILE - addStop $STARTFILE temp/start-${VARIABLE2}-p-${SCREENNAME}.sh -else - echo "#!/bin/bash" > $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "rm -f $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "SCREENNAME=$SCREENNAME" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - addStop $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find $HOMEFOLDER/temp/ -type f -user `whoami` -delete" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find /tmp -user `whoami` -delete" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "crontab -r 2> /dev/null" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - if [ "$VARIABLE5" == "protected" ]; then - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/pserver/ -type d -print0 | xargs -0 chmod 700" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/pserver/ -type f -print0 | xargs -0 chmod 600" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - else - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/server/ -type d -print0 | xargs -0 chmod 700" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/server/ -type f -print0 | xargs -0 chmod 600" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find $USERHOME/$VARIABLE2/ -mindepth 2 -maxdepth 3 \( -type f -or -type l \) ! -name \"*.bz2\" -delete" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - echo "${IONICE}nice -n +19 find $DATADIR -type f -user `whoami` ! -name \"*.bz2\" -delete" >> $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - fi - chmod +x $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh - screen -d -m -S cleanup $HOMEFOLDER/temp/fullstop-${VARIABLE2}-${SCREENNAME}.sh -fi -} - -function addStop { - echo "screen -wipe > /dev/null 2>&1" >> $1 - if [[ `screen -ls | grep $SCREENNAME` ]]; then - SENDTO=`screen -ls | grep $SCREENNAME | awk '{print $1}' | head -n 1` - if [ "$VARIABLE6" == "minecraft" -o "$VARIABLE4" == "minecraft" ]; then - screenEnter $1 - echo "screen -p 0 -S $SENDTO -X stuff \"say SERVER WILL SHUT DOWN IN 10 SECONDS\"" >> $1 - screenEnter $1 - echo "screen -p 0 -S $SENDTO -X stuff \"save-all\"" >> $1 - screenEnter $1 - echo "sleep 10" >> $1 - echo "screen -p 0 -S $SENDTO -X stuff \"stop\"" >> $1 - screenEnter $1 - echo "sleep 5" >> $1 - elif [ "$VARIABLE6" == "srcds_run" -o "$VARIABLE4" == "srcds_run" ]; then - screenEnter $1 - echo "screen -p 0 -S $SENDTO -X stuff \"tv_stoprecord\"" >> $1 - screenEnter $1 - fi - echo 'if [ "`screen -ls | grep $SCREENNAME | wc -l`" == "1" ]; then' >> $1 - echo 'screen -r $SCREENNAME -X quit' >> $1 - echo 'fi' >> $1 - echo "ps x | grep -v '$1' | grep -v '$2' | grep $SCREENNAME | grep -v grep | awk '{print "'$1'"}' | while read PID; do" >> $1 - echo 'kill $PID' >> $1 - echo 'kill -9 $PID' >> $1 - echo 'done' >> $1 - echo 'echo "`date`: Server $VARIABLE3 for user $VARIABLE2 stopped" >> '$LOGDIR'/server.log' >> $1 - else - echo "No screen found: $SCREENNAME" - fi - echo "ps x | grep -v '$1' | grep -v '$2' | grep `echo $SCREENNAME | awk -F '_' '{print $1}'` | grep `echo $SCREENNAME | awk -F '_' '{print $2}'` | grep -v grep | awk '{print "'$1'"}' | while read PID; do" >> $1 - echo 'kill $PID' >> $1 - echo 'kill -9 $PID' >> $1 - echo 'done' >> $1 - echo "ps x | grep -v '$1' | grep -v '$2' | grep 'java' | grep -v grep | awk '{print "'$1'"}' | while read PID; do" >> $1 - echo 'kill $PID' >> $1 - echo 'kill -9 $PID' >> $1 - echo 'done' >> $1 -} - -function screenEnter { - echo "screen -p 0 -S $SENDTO -X stuff $'\n'" >> $1 -} - -function mc_worldsafe { -SENDTO=`screen -ls | grep $VARIABLE2 | awk '{print $1}'` -if [ "$SENDTO" != "" ]; then - screen -p 0 -S $SENDTO -X stuff $'\n' - screen -p 0 -S $SENDTO -X stuff "say SERVER WILL SAVE THE WORLD NOW" - screen -p 0 -S $SENDTO -X stuff $'\n' - screen -p 0 -S $SENDTO -X stuff $'\n' - screen -p 0 -S $SENDTO -X stuff "save-all" - screen -p 0 -S $SENDTO -X stuff $'\n' -fi -} - -function demo_upload { - USERNAME=`echo $VARIABLE2 | awk -F '/' '{print $3}'` - SCREENNAME=`echo $VARIABLE2 | awk -F '/' '{print $5}'` - if [ "$VARIABLE6" == "" ]; then - KEEP='' - else - if [ "$VARIABLE6" == "keep" ]; then - KEEP='-k' - else - KEEP='' - fi - fi - LSOF=`which lsof` - if [ "$LSOF" == "" ]; then KEEP='-k'; fi - if [[ `which zip` ]]; then - if [ "$KEEP" == "" ]; then - KEEP='-m' - fi - COMPRESS="${IONICE}"'nice -n +19 zip -q $KEEP $DEMOPATH/$DEMO.zip $DEMOPATH/$DEMO' - ZIP='zip' - elif [[ `which bzip2` ]]; then - COMPRESS="${IONICE}"'nice -n +19 bzip2 -s -q -9 $KEEP $DEMOPATH/$DEMO' - ZIP='bz2' - fi - if [ "$ZIP" != "" ]; then - cat > $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh <> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'sleep 1' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'done' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'while [ "`ps x | grep -v grep | awk '"'"'{print $7}'"'"' | grep '"'add-${USERNAME}-${SCREENNAME}'"'`" != "" ]; do' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'sleep 1' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'done' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - if [ "$VARIABLE5" == "auto" ]; then - echo 'DEMOPATH=`find -mindepth 1 -maxdepth 1 -type d -name "$VARIABLE4"`' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'tail -f screenlog.0 | while read LINE; do' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' if [[ `echo $LINE | grep "Completed SourceTV demo"` ]]; then' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' DEMO=`echo -n "$LINE" | awk '"'"'{print $4}'"'"' | tr -d '"'"'"'"'"' | tr -d '"'"','"'"'`' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - if [ "$LSOF" != "" ]; then - echo ' if [[ ! `lsof $DEMOPATH/$DEMO` ]]; then' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi - echo " $COMPRESS" >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' wput -q --limit-rate=1024K --remove-source-files --tries 3 --basename="$DEMOPATH" "$DEMOPATH/$DEMO.$ZIP" "$VARIABLE3"' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - if [ "$LSOF" != "" ]; then - echo ' fi' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi - echo ' fi' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'done' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - else - # pid killen und dann neuen loop - echo 'cd `find -mindepth 1 -maxdepth 1 -type d -name "$VARIABLE4"`' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo 'find . -maxdepth 1 -type f -name "*.dem" | while read LINE; do' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' DEMOPATH="`dirname $LINE`/"' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' DEMO="`basename $LINE`/"' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - if [ "$LSOF" != "" ]; then - echo ' if [[ ! `lsof $LINE` ]]; then' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi - echo " $COMPRESS" >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - echo ' wput -q --limit-rate=1024K --remove-source-files --tries 3 --basename="$DEMOPATH" "$DEMOPATH/$DEMO.$ZIP" "$VARIABLE3"' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - if [ "$LSOF" != "" ]; then - echo ' fi' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi - echo 'done' >> $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi - chmod +x $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - screen -d -m -S $USERNAME-$SCREENNAME-upload $TEMPFOLDER/$USERNAME-$SCREENNAME-upload.sh - fi -} - -function copy_addon_files { - cd $ADDONFOLDER - find -type f | grep -i -E -w '(xml|cfg|con|conf|config|gam|ini|txt|vdf|smx|sp|ext|sma|amxx|lua|json)$' | sed 's/\.\///g' | while read FILE; do - FOLDER=`dirname $FILE` - FILENAME=`basename $FILE` - if [ ! -d $GAMEDIR/$FOLDER ]; then - mkdir -p $GAMEDIR/$FOLDER/ - fi - find $GAMEDIR/$FILE -type l -delete > /dev/null 2>&1 - if [ "$FILENAME" == "liblist.gam" -a "$MATCHADDONS" != "1" ]; then - mv $GAMEDIR/$FILE $GAMEDIR/$FILE.old - cp $ADDONFOLDER/$FILE $GAMEDIR/$FILE - elif [ "$FILENAME" == "plugins.ini" -a "$MATCHADDONS" != "1" ]; then - if [ -f $GAMEDIR/$FILE ]; then - cat $ADDONFOLDER/$FILE | while read $LINE; do - if [ `grep "$LINE" $GAMEDIR/$FILE` == "" ]; then - echo $LINE >> $GAMEDIR/$FILE - fi - done - else - cp $ADDONFOLDER/$FILE $GAMEDIR/$FILE - fi - elif [ "$FILENAME" == "gametypes.txt" -a "$MATCHADDONS" != "1" ]; then - if [ "$FOLDER" != "cfg/mani_admin_plugin" ]; then - cp $ADDONFOLDER/$FILE $GAMEDIR/$FILE - fi - elif [ "$MATCHADDONS" == "1" -a ! -f $GAMEDIR/$FILE -a ! -f "$GAMEDIR/$FOLDER/disabled/$FILENAME" ]; then - cp $ADDONFOLDER/$FILE $GAMEDIR/$FILE - elif [ "$MATCHADDONS" != "1" -a ! -f $GAMEDIR/$FILE ]; then - cp $ADDONFOLDER/$FILE $GAMEDIR/$FILE - fi - done - cp -sr $ADDONFOLDER/* $GAMEDIR/ > /dev/null 2>&1 -} - -function sync_addons { - echo "#!/bin/bash" > $HOMEFOLDER/temp/sync-addons.sh - echo "rm -f $HOMEFOLDER/temp/sync-addons.sh" >> $HOMEFOLDER/temp/sync-addons.sh - if [ "$VARIABLE3" != "maps" ]; then - echo "cd $MAPDIR/" >> $HOMEFOLDER/temp/sync-addons.sh - for MAPPACKAGE in $VARIABLE3; do - if [ "$MAPPACKAGE" != "" ]; then - if [ "$SYNCTOOL" == 'rsync' ]; then - echo "$SYNCCMD/mastermaps/$MAPPACKAGE $MAPDIR/" >> $HOMEFOLDER/temp/sync-addons.sh - elif [ "$SYNCTOOL" == 'wget' ]; then - echo "$SYNCCMD/mastermaps/$MAPPACKAGE" >> $TEMPFOLDER/updateSteamCmd.sh - echo "find $MAPDIR/$MAPPACKAGE -name .listing -delete" >> $HOMEFOLDER/temp/sync-addons.sh - fi - echo "find $MAPDIR/$MAPPACKAGE -type d -print0 | xargs -0 chmod 750" >> $HOMEFOLDER/temp/sync-addons.sh - echo "find $MAPDIR/$MAPPACKAGE -type f -print0 | xargs -0 chmod 640" >> $HOMEFOLDER/temp/sync-addons.sh - fi - done - fi - if [ "$VARIABLE4" != "addons" ]; then - echo "cd $ADDONDIR/" >> $HOMEFOLDER/temp/sync-addons.sh - for ADDON in $VARIABLE4; do - if [ "$ADDON" != "" ]; then - if [ "$SYNCTOOL" == 'rsync' ]; then - echo "$SYNCCMD/masteraddons/$ADDON $ADDONDIR/" >> $HOMEFOLDER/temp/sync-addons.sh - elif [ "$SYNCTOOL" == 'wget' ]; then - echo "$SYNCCMD/mastermaps/$ADDON" >> $TEMPFOLDER/updateSteamCmd.sh - echo "find $ADDONDIR/$ADDON -name .listing -delete" >> $HOMEFOLDER/temp/sync-addons.sh - fi - echo "find $ADDONDIR/$ADDON -type d -print0 | xargs -0 chmod 750" >> $HOMEFOLDER/temp/sync-addons.sh - echo "find $ADDONDIR/$ADDON -type f -print0 | xargs -0 chmod 640" >> $HOMEFOLDER/temp/sync-addons.sh - fi - done - fi - chmod +x $HOMEFOLDER/temp/sync-addons.sh - screen -dmS sync-addons $HOMEFOLDER/temp/sync-addons.sh -} - -function sync_server { - echo "#!/bin/bash" > $TEMPFOLDER/sync-server.sh - echo "rm -f $TEMPFOLDER/sync-server.sh" >> $TEMPFOLDER/sync-server.sh - echo "cd $MASTERSERVERDIR/" >> $TEMPFOLDER/sync-server.sh - echo "BOMRM=\"sed \"'s/^\xef\xbb\xbf//g'\"\"" >> $TEMPFOLDER/sync-server.sh - for SERVER in $VARIABLE3; do - if [ "$SERVER" != "" ]; then - if [ "$SYNCTOOL" == 'rsync' ]; then - echo "$SYNCCMD/masterserver/$SERVER $MASTERSERVERDIR/ > $LOGDIR/update-$SERVER.log" >> $TEMPFOLDER/sync-server.sh - echo "$SYNCCMD/conf/fdl-$SERVER.list $HOMEFOLDER/conf/ > $LOGDIR/update-$SERVER.log" >> $TEMPFOLDER/sync-server.sh - elif [ "$SYNCTOOL" == 'wget' ]; then - echo "$SYNCCMD/masterserver/$SERVER > $LOGDIR/update-$SERVER.log" >> $$TEMPFOLDER/sync-server.sh - echo "cd $HOMEFOLDER/conf/ > $LOGDIR/update-$SERVER.log" >> $TEMPFOLDER/sync-server.sh - echo "$SYNCCMD/conf/fdl-$SERVER.list > $LOGDIR/update-$SERVER.log" >> $TEMPFOLDER/sync-server.sh - echo "find $MASTERSERVERDIR/$SERVER -type d -print0 | xargs -0 chmod 750" >> $TEMPFOLDER/sync-server.sh - echo "find $MASTERSERVERDIR/$SERVER -type f ! -perm -750 ! -perm -755 -print0 | xargs -0 chmod 640" >> $TEMPFOLDER/sync-server.sh - echo "find $MASTERSERVERDIR/$SERVER -name .listing -delete" >> $TEMPFOLDER/sync-server.sh - fi - echo "find $MASTERSERVERDIR/$SERVER/ -maxdepth 2 -type f -name 'subscribed_file_ids.txt' -o -name 'subscribed_collection_ids.txt' | while read file; do rm -f "'"$file"'"; done" >> $TEMPFOLDER/sync-server.sh - if [ "$VARIABLE4" != "" ]; then - echo "VARIABLE4=$VARIABLE4" >> $TEMPFOLDER/sync-server.sh - echo "SERVER=$SERVER" >> $TEMPFOLDER/sync-server.sh - echo 'I=0' >> $TEMPFOLDER/sync-server.sh - echo 'CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$SERVER | $BOMRM`' >> $TEMPFOLDER/sync-server.sh - echo 'while [ "$CHECK" != "ok" -a "$I" -le "10" ]; do' >> $TEMPFOLDER/sync-server.sh - echo 'if [ "$CHECK" == "" ]; then' >> $TEMPFOLDER/sync-server.sh - echo 'I=11' >> $TEMPFOLDER/sync-server.sh - echo 'else' >> $TEMPFOLDER/sync-server.sh - echo 'sleep 30' >> $TEMPFOLDER/sync-server.sh - echo 'I=$[I+1]' >> $TEMPFOLDER/sync-server.sh - echo 'CHECK=`wget -q --timeout=10 --no-check-certificate -O - $VARIABLE4/get_password.php?w=ms\&shorten=$SERVER | $BOMRM`' >> $TEMPFOLDER/sync-server.sh - echo 'fi' >> $TEMPFOLDER/sync-server.sh - echo 'done' >> $TEMPFOLDER/sync-server.sh - fi - fi - done - chmod +x $TEMPFOLDER/sync-server.sh - screen -dmS sync-server $TEMPFOLDER/sync-server.sh -} - -function add_addon { - USERHOME='/home' - if [ "$VARIABLE1" == "addaddon" -a "$VARIABLE6" != "" ]; then - USERHOME=$VARIABLE6 - elif [ "$VARIABLE1" != "addaddon" -a "$VARIABLE5" != "" ]; then - USERHOME=$VARIABLE5 - fi - if [ "$VARIABLE5" != "" -a "$VARIABLE5" != "none" ]; then - if [ "`find $USERHOME/$VARIABLE4 -mindepth 1 -maxdepth 3 -type d -name ${VARIABLE5} | wc -l`" == "1" ]; then - GAMEDIR=`find $USERHOME/$VARIABLE4 -mindepth 1 -maxdepth 3 -type d -name "$VARIABLE5" | head -n 1` - else - GAMEDIR=`find $USERHOME/$VARIABLE4 -mindepth 1 -maxdepth 1 -type d -name "$VARIABLE5" | head -n 1` - fi - elif [ -f $USERHOME/$VARIABLE4/hlds_run -a -d $USERHOME/$VARIABLE4/czero ]; then - GAMEDIR="$USERHOME/$VARIABLE4/czero" - elif [ -f $USERHOME/$VARIABLE4/srcds_run -o -f $USERHOME/$VARIABLE4/hlds_run ]; then - GAMEDIR="`find $USERHOME/$VARIABLE4 -mindepth 1 -maxdepth 1 -type d -name csgo -o -name cstrike -o -name dod -o -name hl2mp -o -name tf | head -n1`" - fi - if [ "$GAMEDIR" == "" ]; then - GAMEDIR="$USERHOME/$VARIABLE4" - fi - GAMEDIR=`echo $GAMEDIR | sed 's/\/\//\//g'` - GAMEDIR=`echo $GAMEDIR | sed 's/\/\//\//g'` - COPYFILES=0 - if [ "$VARIABLE2" == "map" -a "$VARIABLE3" != "" -a -d $MAPDIR/$VARIABLE3 ]; then - ADDONFOLDER=$MAPDIR/$VARIABLE3 - cd $ADDONFOLDER - map_list - COPYFILES=1 - elif [ "$VARIABLE2" == "tool" -a "$VARIABLE3" != "" -a -d $ADDONDIR/$VARIABLE3 ]; then - ADDONFOLDER=$ADDONDIR/$VARIABLE3 - cd $ADDONFOLDER - COPYFILES=1 - fi - if [ "$COPYFILES" == "1" ]; then - USER=`echo $GAMEDIR | awk -F/ '{print $3}'` - copy_addon_files& - if [ -f $LOGDIR/addons.log ]; then - echo "`date`: Installed $VARIABLE3 at the server $GAMEDIR for user $USER" >> $LOGDIR/addons.log - fi - fi -} - -function del_addon_files { - find -mindepth 1 -type f | sed 's/\.\///g' | while read FILES; do - if [ "`basename $FILES`" == "liblist.gam" ]; then - mv $GAMEDIR/$FILES.old $GAMEDIR/$FILES - elif [ "`basename $FILES`" == "plugins.ini" ]; then - if [ -f $HOMEFOLDER/temp/$USER.pluginlist.temp ]; then rm -f $HOMEFOLDER/temp/$USER.pluginlist.temp; fi - cat $GAMEDIR/$FILES | while read LINE; do - if [[ `grep "$LINE" $FILES` == "" ]]; then echo "$LINE" >> $HOMEFOLDER/temp/$USER.pluginlist.temp; fi - done - cp $HOMEFOLDER/temp/$USER.pluginlist.temp $GAMEDIR/$FILES - rm -f $HOMEFOLDER/temp/$USER.pluginlist.temp - else - rm -rf "$GAMEDIR/$FILES" > /dev/null 2>&1 - if [ "$FILES" == "liblist.gam" ]; then mv $GAMEDIR/$FILES.old $GAMEDIR/$FILES > /dev/null 2>&1; fi - fi - done - cd $GAMEDIR - find -mindepth 1 -type d -empty -delete - if [ "$VARIABLE6" != "" -a "$VARIABLE6" != "none" ]; then - for FOLDER in $VARIABLE6; do - find -mindepth 1 -name "$FOLDER" | while read FOLDERS; do - if [ -d $FOLDERS ]; then rm -rf $FOLDERS; fi - done - done - fi -} - -function del_addon { - if [ "${VARIABLE4:0:1}" != "/" ]; then VARIABLE4="/home/$VARIABLE4"; fi - VARIABLE4=`echo $VARIABLE4 | sed 's/\/\//\//g'` - if [ "$VARIABLE2" == "map" ]; then - ADDONFOLDER=$MAPDIR/$VARIABLE3 - if [ ! -d $ADDONFOLDER ]; then exit 0; fi - elif [ "$VARIABLE2" == "tool" ]; then - ADDONFOLDER=$ADDONDIR/$VARIABLE3 - if [ ! -d $ADDONFOLDER ]; then exit 0; fi - else - exit 0 - fi - cd $ADDONFOLDER - if [ "$VARIABLE5" != "" -a "$VARIABLE5" != "none" ]; then - if [ "`find $VARIABLE4 -mindepth 1 -maxdepth 3 -type d -name ${VARIABLE5} | wc -l`" == "1" ]; then - GAMEDIR=`find $VARIABLE4 -mindepth 1 -maxdepth 3 -type d -name "$VARIABLE5" | head -n 1` - else - GAMEDIR=`find $VARIABLE4 -mindepth 1 -maxdepth 1 -type d -name "$VARIABLE5" | head -n 1` - fi - else - GAMEDIR="$VARIABLE4" - fi - USER=`echo $GAMEDIR | awk -F/ '{print $3}'` - del_addon_files& - if [ -f $LOGDIR/addons.log ]; then - echo "`date`: Removed $VARIABLE3 from the server $GAMEDIR for user $USER" >> $LOGDIR/addons.log - fi -} - -function fdl_update { - SHORTEN=`echo $VARIABLE3 | awk -F "/" '{print $2}'` - if [ "`echo $SHORTEN | grep '-'`" == "" ]; then - SHORTEN=$SHORTEN - else - SHORTEN=`echo $SHORTEN | awk -F "-" '{print $1}'` - fi - if [ -f $HOMEFOLDER/conf/fdl-$SHORTEN.list ]; then - USERHOME='/home' - if [ "$VARIABLE7" != "" ]; then USERHOME=$VARIABLE7; fi - if [ "$VARIABLE6" == "protected" ]; then - SERVERDIR=$USERHOME/$VARIABLE2/pserver/$VARIABLE3 - else - SERVERDIR=$USERHOME/$VARIABLE2/server/$VARIABLE3 - fi - SERVERDIR=`echo $SERVERDIR | sed 's/\/\//\//g'` - SPORT=`echo $VARIABLE3 | awk -F "/" '{print $1}'` - if [ ! -d $HOMEFOLDER/conf ]; then - mkdir -p $HOMEFOLDER/conf - chmod 770 $HOMEFOLDER/conf - fi - cd $SERVERDIR - if [ "`find -maxdepth 2 -name srcds_run`" != "" ]; then - GAMETYPE="hl2" - if [ "$VARIABLE5" == "left4dead2" ]; then - GSMODFOLDER='left4dead2/left4dead2' - SERVERDIR=`readlink -f ` - else - GSMODFOLDER=`find -mindepth 1 -maxdepth 2 -type d -name "$VARIABLE5"` - SERVERDIR=`readlink -f $GSMODFOLDER` - fi - elif [ "`find -maxdepth 1 -name hlds_run`" != "" ]; then - GAMETYPE="hl1" - GSMODFOLDER=`find -mindepth 1 -maxdepth 1 -type d -name "$VARIABLE5"` - SERVERDIR=`readlink -f $GSMODFOLDER` - elif [ "`find -maxdepth 2 -name cod4_lnxded`" != "" ]; then - GAMETYPE="cod" - GSMODFOLDER='.' - SERVERDIR=`readlink -f $GSMODFOLDER` - fi - if [ -f $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh ]; then - rm -f $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - fi - PATTERN="\.log\|\.txt\|\.cfg\|\.vdf\|\.db\|\.dat\|\.ztmp\|\.blib\|log\/\|logs\/\|downloads\/\|DownloadLists\/\|metamod\/\|amxmodx\/\|hl\/\|hl2\/\|cfg\/\|addons\/\|bin\/\|classes/" - echo "#!/bin/bash" > $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "rm -f $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "GAMETYPE=$GAMETYPE" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "HOMEFOLDER=$HOMEFOLDER" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "VARIABLE2=$VARIABLE2" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "VARIABLE3=$VARIABLE3" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "VARIABLE4=$VARIABLE4" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "VARIABLE5=$VARIABLE5" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "FTPUPLOADLIMIT=$FTPUPLOADLIMIT" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "SHORTEN=$SHORTEN" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "DATADIR=$DATADIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "LOGDIR=$LOGDIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "cd $SERVERDIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - if [ "$GAMETYPE" == "hl1" ]; then - SEARCHFOLDERS="." - elif [ "$GAMETYPE" == "hl2" ]; then - if [ ! -d $HOMEFOLDER/fdl_data/$GAMETYPE ]; then - mkdir -p $HOMEFOLDER/fdl_data/$GAMETYPE - find $HOMEFOLDER/fdl_data/$GAMETYPE -maxdepth 1 -type d -user `whoami` -exec chmod 770 {} \; - fi - SEARCHFOLDERS="particles/ maps/ materials/ resource/ models/ sound/" - elif [ "$GAMETYPE" == "cod" ]; then - SEARCHFOLDERS="usermaps/ mods/" - fi - echo "SEARCHFOLDERS='$SEARCHFOLDERS'" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "PATTERN='$PATTERN'" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - if [ "$GAMETYPE" == "hl2" ]; then - echo 'find $SEARCHFOLDERS -type f 2> /dev/null | grep -v "$PATTERN" | while read FILTEREDFILE1; do' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILTEREDFILES=${FILTEREDFILE1//\.\//}' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILENAME=`basename $FILTEREDFILES`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [[ ! `grep "$FILTEREDFILES" $HOMEFOLDER/conf/fdl-$SHORTEN.list` ]]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FDLDATADIR=$DATADIR/$GAMETYPE/$SHORTEN/`dirname "$FILTEREDFILES"`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ ! -d $FDLDATADIR ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' mkdir -p $FDLDATADIR' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 770 $FDLDATADIR' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo " cd $SERVERDIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ "`head -n 1 \"$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat\"`" != "`'"${IONICE}"'nice -n +19 md5sum \"$FILTEREDFILES\" | awk '"'"'{print $1}'"'"'`" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 md5sum "$FILTEREDFILES" | awk '"'"'{print $1}'"'"' > "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 rm -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 bzip2 -k -s -q -9 "$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 mv "$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 660 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --reupload --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2:Updated $VARIABLE5 file `basename $FILTEREDFILES`" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --dont-continue --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME checked" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 md5sum "$FILTEREDFILES" | awk '"'"'{print $1}'"'"' > "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 bzip2 -k -s -q -9 "$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 mv "$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 660 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --dont-continue --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: Added $SHORTEN file `basename $FILTEREDFILES`" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'done' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "cd $SERVERDIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'find $SEARCHFOLDERS -type l 2> /dev/null | grep -v "$PATTERN" | while read FILTEREDFILE1; do' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILTEREDFILES=${FILTEREDFILE1//\.\//}' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILENAME=`basename $FILTEREDFILES`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [[ ! `grep "$FILTEREDFILES" $HOMEFOLDER/conf/fdl-$SHORTEN.list` ]]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FDLDATADIR=$DATADIR/$GAMETYPE/$SHORTEN/`dirname "$FILTEREDFILES"`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ ! -d $FDLDATADIR ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' mkdir -p $FDLDATADIR' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 770 $FDLDATADIR' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo " cd $SERVERDIR" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ "`head -n 1 \"$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat\"`" != "`'"${IONICE}"'nice -n +19 md5sum \"$FILTEREDFILES\" | awk '"'"'{print $1}'"'"'`" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 md5sum "$FILTEREDFILES" | awk '"'"'{print $1}'"'"' > "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 rm -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [ -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 rm -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 cp "$FILTEREDFILES" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 bzip2 -s -q -9 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 660 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --reupload --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: Updated $VARIABLE5 file `basename $FILTEREDFILES`" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --dont-continue --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME checked" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 md5sum "$FILTEREDFILES" | awk '"'"'{print $1}'"'"' > "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 cp "$FILTEREDFILES" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' rm -f "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' '"${IONICE}"'nice -n +19 bzip2 -s -q -9 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' chmod 660 "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.bz2" "$DATADIR/$GAMETYPE/$SHORTEN/$FILTEREDFILES.stat"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' cd $DATADIR/$GAMETYPE/$SHORTEN' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -q --dont-continue --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES.bz2" "$VARIABLE4/$SHORTEN/"' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: Added $SHORTEN file `basename $FILTEREDFILES`" >> $LOGDIR/fdl-hl2.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'done' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "find $HOMEFOLDER/fdl_data/$GAMETYPE -type d -user `id -nu` -exec chmod 770 {} \;" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo "find $HOMEFOLDER/fdl_data/$GAMETYPE -type f -user `id -nu` -exec chmod 660 {} \;" >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - elif [ "$GAMETYPE" == "hl1" ]; then - echo 'find $SEARCHFOLDERS -type l -or -type f 2> /dev/null | grep -v "$PATTERN" | while read FILTEREDFILE1; do' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILTEREDFILES=${FILTEREDFILE1//\.\//}' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [[ ! `grep "$FILTEREDFILES" $HOMEFOLDER/conf/fdl-$SHORTEN.list` ]]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'FILENAME=`basename $FILTEREDFILES`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'if [ "`wput -q -nv --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES" $VARIABLE4/$SHORTEN/ | grep \"Skipping file\"`" != "" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -qN --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES" $VARIABLE4/$SHORTEN/' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME checked" >> $LOGDIR/fdl-hl1.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME uploaded" >> $LOGDIR/fdl-hl1.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'done' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - elif [ "$GAMETYPE" == "cod" ]; then - echo 'find $SEARCHFOLDERS -type l -or -type f \( -iname "*.ff" -or -iname "*.iwd" \) 2> /dev/null | grep -v "$PATTERN" | while read FILTEREDFILE1; do' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' FILTEREDFILES=${FILTEREDFILE1//\.\//}' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' if [[ ! `grep "$FILTEREDFILES" $HOMEFOLDER/conf/fdl-$SHORTEN.list` ]]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'FILENAME=`basename $FILTEREDFILES`' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'if [ "`wput -q -nv --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES" $VARIABLE4/$SHORTEN/ | grep \"Skipping file\"`" != "" ]; then' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' wput -qN --limit-rate=$FTPUPLOADLIMIT "$FILTEREDFILES" $VARIABLE4/$SHORTEN/' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME checked" >> $LOGDIR/fdl-hl1.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'else' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo ' echo "`date`: $VARIABLE2: $VARIABLE5 file $FILENAME uploaded" >> $LOGDIR/fdl-hl1.log' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'fi' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - echo 'done' >> $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - fi - screen -wipe > /dev/null 2>&1 - if [[ `ps fx| grep "fdl-$VARIABLE2-$SPORT-$SHORTEN" | grep -v grep` ]]; then - rm -f $HOMEFOLDER/temp/$VARIABLE2-$SPORT-$SHORTEN.sh - else - cd $HOMEFOLDER/temp/ - chmod +x $VARIABLE2-$SPORT-$SHORTEN.sh - screen -dmS fdl-$VARIABLE2-$SPORT-$SHORTEN ./$VARIABLE2-$SPORT-$SHORTEN.sh - find $LOGDIR/ -maxdepth 1 -type f -user `whoami` -exec chmod 660 {} \; - fi - fi -} - -function update_status { -UPDATESTATUS=":" -for GAME in ${VARIABLE2[@]}; do - if [[ `ps x | grep "$GAME.update" | grep -v 'grep'` ]]; then - UPDATESTATUS="$UPDATESTATUS$GAME=1:" - else - UPDATESTATUS="$UPDATESTATUS$GAME=0:" - fi -done -if [[ `ps x | grep "SteamCmdUpdate-Screen" | grep -v 'grep'` ]]; then - UPDATESTATUS=$UPDATESTATUS"steamcmd=1:" -else - UPDATESTATUS=$UPDATESTATUS"steamcmd=0:" -fi -if [[ `ps x | grep "sync-server" | grep -v 'grep'` ]]; then - UPDATESTATUS=$UPDATESTATUS"sync=1:" -else - UPDATESTATUS=$UPDATESTATUS"sync=0:" -fi -echo $UPDATESTATUS -} - -case "$1" in - steamCmd) - rsyncExists - steamCmdUpdate - wget_remove & - ;; - noSteamCmd) - rsyncExists - noSteamCmdUpdate - wget_remove & - ;; - mcUpdate) - rsyncExists - noSteamCmdUpdate - wget_remove & - ;; - delete) - server_delete - ;; - grestart) - server_stop - server_start& - ;; - gstop) - server_stop& - ;; - addonmatch) - match_addons& - ;; - mapmatch) - match_maps& - ;; - demoupload) - demo_upload - ;; - add) - add_customer - wget_remove & - ;; - useradd) - add_user - wget_remove & - ;; - usermod) - mod_user - wget_remove & - ;; - delscreen) - del_customer_screen - ;; - delCustomer) - customerDelete - wget_remove & - ;; - delSingleUser) - user_single_delete - ;; - mod) - mod_customer - wget_remove & - ;; - addserver) - add_customer_server - ;; - delserver) - del_customer_server - ;; - reinstserver) - reinst_customer_server - ;; - migrateserver) - migration - ;; - syncaddons) - rsyncExists - sync_addons - ;; - syncserver) - rsyncExists - sync_server - ;; - addaddon) - add_addon - ;; - deladdon) - del_addon - ;; - fastdl) - FTPUPLOADLIMIT="1024K" - fdl_update - ;; - stopall) - crontab -r - screen -wipe > /dev/null 2>&1 - pkill -u `whoami` - ;; - install) - install_control - ;; - move) - port_move - ;; - ip_port_change) - move_server - ;; - mc_ws) - mc_worldsafe - ;; - backup) - FTPUPLOADLIMIT="5096K" - backup_servers - ;; - restore) - FTPUPLOADLIMIT="5096K" - restore_backup - ;; - updatestatus) - update_status - wget_remove & - ;; - update) - ISROOT=1 - updatecheck - ;; - generateKey) - publicKeyGenerate - ;; - *) - echo "Current version: $CVERSION" - wget_remove & - ;; -esac -exit 0 diff --git a/server/easy-wi_install.sh b/server/easy-wi_install.sh deleted file mode 100644 index ee0beaf8..00000000 --- a/server/easy-wi_install.sh +++ /dev/null @@ -1,1593 +0,0 @@ -#!/bin/bash - -# Author: Ulrich Block -# -# This file is part of Easy-WI. -# -# Easy-WI is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Easy-WI is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Easy-WI. If not, see . -# -# Diese Datei ist Teil von Easy-WI. -# -# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen -# der GNU General Public License, wie von der Free Software Foundation, -# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren -# veroeffentlichten Version, weiterverbreiten und/oder modifizieren. -# -# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber -# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite -# Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. -# Siehe die GNU General Public License fuer weitere Details. -# -# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -# Programm erhalten haben. Wenn nicht, siehe . - -function greenMessage { - echo -e "\\033[32;1m${@}\033[0m" -} - -function cyanMessage { - echo -e "\\033[36;1m${@}\033[0m" -} - -function redMessage { - echo -e "\\033[31;1m${@}\033[0m" -} - -function yellowMessage { - echo -e "\\033[33;1m${@}\033[0m" -} - -function errorAndQuit { - errorAndExit "Exit now!" -} - -function errorAndExit { - redMessage ${@} - exit 0 -} - -function errorAndContinue { - redMessage "Invalid option." - continue -} - -function removeIfExists { - if [ "$1" != "" -a -f "$1" ]; then - rm -f $1 - fi -} - -function runSpinner { - - SPINNER=("-" "\\" "|" "/") - - for SEQUENCE in `seq 1 $1`; do - for I in "${SPINNER[@]}"; do - echo -ne "\b$I" - sleep 0.1 - done - done -} - -function okAndSleep { - greenMessage $1 - sleep 1 -} - -function makeDir { - if [ "$1" != "" -a ! -d $1 ]; then - mkdir -p $1 - fi -} - -function backUpFile { - if [ ! -f "$1.easy-install.backup" ]; then - cp "$1" "$1.easy-install.backup" - fi -} - -function checkInstall { - if [ "`dpkg-query -s $1 2>/dev/null`" == "" ]; then - okAndSleep "Installing package $1" - apt-get install -y $1 - fi -} - -INSTALLER_VERSION="1.6" -OS="" -USERADD=`which useradd` -USERMOD=`which usermod` -USERDEL=`which userdel` -GROUPADD=`which groupadd` -MACHINE=`uname -m` -LOCAL_IP=`ip route get 8.8.8.8 | awk '{print $NF; exit}'` - -if [ "$LOCAL_IP" == "" ]; then - HOST_NAME=`hostname -f | awk '{print tolower($0)}'` -else - HOST_NAME=`getent hosts $LOCAL_IP | awk '{print tolower($2)}' | head -n 1` -fi - -cyanMessage "Checking for the latest latest installer" -LATEST_VERSION=`wget -q --timeout=60 -O - http://l.easy-wi.com/installer_version.php | sed 's/^\xef\xbb\xbf//g'` - -if [ "`printf "${LATEST_VERSION}\n${INSTALLER_VERSION}" | sort -V | tail -n 1`" != "$INSTALLER_VERSION" ]; then - errorAndExit "You are using the old version ${INSTALLER_VERSION}. Please upgrade to version ${LATEST_VERSION} and retry." -else - okAndSleep "You are using the up to date version ${INSTALLER_VERSION}." -fi - -# We need to be root to install and update -if [ "`id -u`" != "0" ]; then - cyanMessage "Change to root account required" - su - -fi - -if [ "`id -u`" != "0" ]; then - errorAndExit "Still not root, aborting" -fi - -# Debian and its derivatives store their version at /etc/debian_version -if [ -f /etc/debian_version ]; then - - cyanMessage " " - okAndSleep "Update the system packages to the latest version? Required, as otherwise dependencies might brake!" - - OPTIONS=("Yes" "Quit") - select UPDATE_UPGRADE_SYSTEM in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y - - checkInstall curl - checkInstall debconf-utils - checkInstall lsb-release - - OS=`lsb_release -i 2> /dev/null | grep 'Distributor' | awk '{print tolower($3)}'` - OSVERSION=`lsb_release -r 2> /dev/null | grep 'Release' | awk '{print $2}'` - OSBRANCH=`lsb_release -c 2> /dev/null | grep 'Codename' | awk '{print $2}'` -fi - -if [ "$OS" == "" ]; then - errorAndExit "Error: Could not detect OS. Currently only Debian and Ubuntu are supported. Aborting!" -else - okAndSleep "Detected OS $OS" -fi - -if [ "$OSBRANCH" == "" ]; then - errorAndExit "Error: Could not detect branch of OS. Aborting" -else - okAndSleep "Detected branch $OSBRANCH" -fi - -cyanMessage " " -cyanMessage "What shall be installed/prepared?" - -OPTIONS=("Gameserver Root" "Voicemaster" "Easy-WI Webpanel" "Webspace Root" "MySQL" "Quit") -select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4|5 ) break;; - 6 ) errorAndQuit;; - *) errorAndContinue;; - esac -done - -if [ "$OPTION" == "Easy-WI Webpanel" ]; then - INSTALL="EW" -elif [ "$OPTION" == "Gameserver Root" ]; then - INSTALL="GS" -elif [ "$OPTION" == "Voicemaster" ]; then - INSTALL="VS" -elif [ "$OPTION" == "Webspace Root" ]; then - INSTALL="WR" -elif [ "$OPTION" == "MySQL" ]; then - INSTALL="MY" -fi - -OTHER_PANEL="" - -if [ "$INSTALL" != "VS" ]; then - if [ -f /etc/init.d/psa ]; then - OTHER_PANEL="Plesk" - elif [ -f /usr/local/vesta/bin/v-change-user-password ]; then - OTHER_PANEL="VestaCP" - elif [ -d /root/confixx ]; then - OTHER_PANEL="Confixx" - elif [ -d /var/www/froxlor ]; then - OTHER_PANEL="Froxlor" - elif [ -d /etc/imscp ]; then - OTHER_PANEL="i-MSCP" - elif [ -d /usr/local/ispconfig ]; then - OTHER_PANEL="ISPConfig" - elif [ -d /var/cpanel ]; then - OTHER_PANEL="cPanel" - elif [ -d /usr/local/directadmin ]; then - OTHER_PANEL="DirectAdmin" - fi -fi - -if [ "$OTHER_PANEL" != "" ]; then - if [ "$INSTALL" == "GS" ]; then - yellowMessage " " - yellowMessage "Warning an installation of the control panel $OTHER_PANEL has been detected." - yellowMessage "If you continue the installer might end up breaking $OTHER_PANEL or same parts of Easy-WI might not work." - OPTIONS=("Continue" "Quit") - select UPDATE_UPGRADE_SYSTEM in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - else - errorAndExit "Aborting as the risk of breaking the installed panel $OTHER_PANEL is too high." - fi -fi - -# Run the domain/IP check up front to avoid late error out. -if [ "$INSTALL" == "EW" ]; then - - cyanMessage " " - cyanMessage "At which URL/Domain should Easy-Wi be placed?" - OPTIONS=("$HOST_NAME" "$LOCAL_IP" "Other" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Other" ]; then - cyanMessage " " - cyanMessage "Please specify the IP or domain Easy-Wi should run at." - read IP_DOMAIN - else - IP_DOMAIN=$OPTION - fi - - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $IP_DOMAIN`" == "" -a "`grep -E '^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)*[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}$' <<< $IP_DOMAIN`" == "" ]; then - errorAndExit "Error: $IP_DOMAIN is neither a domain nor an IPv4 address!" - fi -fi - -# Run the TS3 server version detect up front to avoid user executing steps first and fail at download last. -if [ "$INSTALL" == "VS" ]; then - - if [ "$MACHINE" == "x86_64" ]; then - ARCH="amd64" - elif [ "$MACHINE" == "i386" ]||[ "$MACHINE" == "i686" ]; then - ARCH="x86" - else - errorAndExit "$MACHINE is not supported!" - fi - - okAndSleep "Searching latest build for hardware type $MACHINE with arch $ARCH." - - for VERSION in `curl -s "http://dl.4players.de/ts/releases/?C=M;O=D" | grep -Po '(?<=href=")[0-9]+(\.[0-9]+){2,3}(?=/")' | sort -Vr`; do - - DOWNLOAD_URL_VERSION="http://dl.4players.de/ts/releases/$VERSION/teamspeak3-server_linux_$ARCH-$VERSION.tar.bz2" - STATUS=`curl -I $DOWNLOAD_URL_VERSION 2>&1 | grep "HTTP/" | awk '{print $2}'` - - if [ "$STATUS" == "200" ]; then - DOWNLOAD_URL=$DOWNLOAD_URL_VERSION - break - fi - done - - if [ "$STATUS" == "200" -a "$DOWNLOAD_URL" != "" ]; then - okAndSleep "Detected latest server version as $VERSION with download URL $DOWNLOAD_URL" - else - errorAndExit "Could not detect latest server version" - fi -fi - -# If we need to install and configure a webspace than we need to identify the groupID -if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - - WEBGROUPID=`getent group www-data | awk -F ':' '{print $3}'` - - if [ "$INSTALL" == "EW" ]; then - OPTION="Yes" - else - cyanMessage " " - cyanMessage "Found group www-data with group ID $WEBGROUPID. Use as webservergroup?" - - OPTIONS=("Yes" "No" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$OPTION" == "No" ]; then - - cyanMessage "Please name the group you want to use as webservergroup" - read WEBGROUP - - WEBGROUPID=`getent group $WEBGROUP | awk -F ':' '{print $3}'` - - if [ "$WEBGROUPID" == "" ]; then - $GROUPADD $WEBGROUP - WEBGROUPID=`getent group $WEBGROUP | awk -F ':' '{print $3}'` - fi - fi - - if [ "$WEBGROUPID" == "" ]; then - errorAndExit "Fatal Error: missing webservergroup ID" - fi -fi - -if [ "$INSTALL" != "MY" ]; then - - cyanMessage "Please enter the name of the masteruser. If it does not exists, the installer will create it." - read MASTERUSER - - if [ "$MASTERUSER" == "" ]; then - errorAndExit "Fatal Error: No masteruser specified" - fi - - if [ "`id $MASTERUSER 2> /dev/null`" == "" ]; then - - if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - $USERADD -m -b /home -s /bin/bash -g $WEBGROUPID $MASTERUSER - else - - if [ -d /home/$MASTERUSER ]; then - $GROUPADD $MASTERUSER - $USERADD -d /home/$MASTERUSER -s /bin/bash -g $MASTERUSER $MASTERUSER - else - $GROUPADD $MASTERUSER - $USERADD -m -b /home -s /bin/bash -g $MASTERUSER $MASTERUSER - fi - fi - - elif [ "$INSTALL" != "VS" -a "$INSTALL" != "MY" ]; then - - okAndSleep "User \"$MASTERUSER\" found setting group \"$MASTERUSER\" as mastegroup" - - if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - $USERMOD -G $WEBGROUPID $MASTERUSER - else - - if [ "`getent group $MASTERUSER`" == "" ]; then - $GROUPADD $MASTERUSER - fi - - $USERMOD -G $MASTERUSER $MASTERUSER - fi - else - okAndSleep "User \"$MASTERUSER\" already exists." - fi - - cyanMessage " " - cyanMessage "Create key or set password for login?" - cyanMessage "Safest way of login is a password protected key." - - if [ "$INSTALL" == "EW" ]; then - cyanMessage "Neither is not required, when installing Easy-WI Webpanel." - fi - - OPTIONS=("Create key" "Set password" "Skip" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Create key" ]; then - - if [ -d /home/$MASTERUSER/.ssh ]; then - rm -rf /home/$MASTERUSER/.ssh - fi - - mkdir -p /home/$MASTERUSER/.ssh - chown $MASTERUSER:$MASTERUSER /home/$MASTERUSER/.ssh - cd /home/$MASTERUSER/.ssh - - cyanMessage " " - cyanMessage "It is recommended but not required to set a password" - su -c "ssh-keygen -t rsa" $MASTERUSER - - KEYNAME=`find -maxdepth 1 -name "*.pub" | head -n 1` - - if [ "$KEYNAME" != "" ]; then - su -c "cat $KEYNAME >> authorized_keys" $MASTERUSER - else - redMessage "Error: could not find a key. You might need to create one manually at a later point." - fi - - elif [ "$OPTION" == "Set password" ]; then - passwd $MASTERUSER - fi -fi - -# only in case we want to manage webspace we need the additional skel dir -if [ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ]; then - makeDir /home/$MASTERUSER/sites-enabled/ - makeDir /home/$MASTERUSER/skel/htdocs - makeDir /home/$MASTERUSER/skel/logs - makeDir /home/$MASTERUSER/skel/session - makeDir /home/$MASTERUSER/skel/tmp -fi - -if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" -o "$INSTALL" == "MY" ]; then - - if [ "$OS" == "debian" -a "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Use dotdeb.org repository for more up to date server and PHP versions?" - - OPTIONS=("Yes" "No" "Quit") - select DOTDEB in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$DOTDEB" == "Yes" ]; then - if [ "`grep 'packages.dotdeb.org' /etc/apt/sources.list`" == "" ]; then - - okAndSleep "Adding entries to /etc/apt/sources.list" - - if [ "$OSBRANCH" == "squeeze" -o "$OSBRANCH" == "wheezy" ]; then - checkInstall python-software-properties - elif [ "$OSBRANCH" == "jessie" ]; then - checkInstall software-properties-common - fi - - add-apt-repository "deb http://packages.dotdeb.org $OSBRANCH all" - add-apt-repository "deb-src http://packages.dotdeb.org $OSBRANCH all" - curl --remote-name http://www.dotdeb.org/dotdeb.gpg - apt-key add dotdeb.gpg - removeIfExists dotdeb.gpg - apt-get update - fi - fi - fi - - if [ "$INSTALL" != "MY" ]; then - cyanMessage " " - cyanMessage "Please select the webserver you would like to use" - fi - - if [ "$INSTALL" == "EW" ]; then - - cyanMessage "Apache is recommended in case you want to run additional sites on this host." - cyanMessage "Nginx is recommended if the server should only run the Easy-WI Web Panel." - - OPTIONS=("Nginx" "Apache" "Quit") - select WEBSERVER in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - elif [ "$INSTALL" != "MY" ]; then - - cyanMessage "Nginx is recommended for FastDL and few but high efficient vhosts" - cyanMessage "Apache is recommended in case you want to run many PHP supporting Vhosts aka mass web hosting" - - OPTIONS=("Nginx" "Apache" "Lighttpd" "None" "Quit") - select WEBSERVER in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4 ) break;; - 5 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$WEBSERVER" == "Nginx" -a "$INSTALL" != "MY" ]; then - checkInstall nginx-full - elif [ "$WEBSERVER" == "Lighttpd" -a "$INSTALL" != "MY" ]; then - checkInstall lighttpd - elif [ "$WEBSERVER" == "Apache" -a "$INSTALL" != "MY" ]; then - checkInstall apache2 - fi - - if [ "$INSTALL" == "EW" ]; then - - okAndSleep "Please note that Easy-Wi requires a MySQL or MariaDB installed and will install MySQL if no DB is installed" - - if [ "`ps ax | grep mysql | grep -v grep`" == "" ]; then - SQL="MySQL" - else - SQL="" - fi - - else - - cyanMessage " " - cyanMessage "Please select if an which database server to install." - cyanMessage "Select \"None\" in case this server should host only Fastdownload webspace." - - OPTIONS=("MySQL" "MariaDB" "None" "Quit") - select SQL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$SQL" == "MySQL" -o "$SQL" == "MariaDB" ]; then - if [ "`ps fax | grep 'mysqld' | grep -v 'grep'`" ]; then - - cyanMessage " " - cyanMessage "Please provide the root password for the MySQL Database." - read MYSQL_ROOT_PASSWORD - - mysql -uroot -p$MYSQL_ROOT_PASSWORD -e exit 2> /dev/null - ERROR_CODE=$? - - until [ $ERROR_CODE == 0 ]; do - - cyanMessage "Password incorrect, please provide the root password for the MySQL Database." - read MYSQL_ROOT_PASSWORD - - mysql -uroot -p$MYSQL_ROOT_PASSWORD -e exit 2> /dev/null - ERROR_CODE=$? - done - - else - until [ "$MYSQL_ROOT_PASSWORD" != "" ]; do - cyanMessage "Please provide the root password for the MySQL Database." - read MYSQL_ROOT_PASSWORD - done - fi - - export DEBIAN_FRONTEND="noninteractive" - echo "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections - echo "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | debconf-set-selections - fi - - if [ "$SQL" == "MySQL" ]; then - - apt-get install mysql-server mysql-client mysql-common -y - - elif [ "$SQL" == "MariaDB" ]; then - - RUNUPDATE=0 - - if ([ "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "8.0" -o "$OS" == "ubuntu" ] && [ "`grep '/mariadb/' /etc/apt/sources.list`" == "" ]); then - - checkInstall python-software-properties - apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db - - if [ "$SQL" == "MariaDB" -a "`apt-cache search mariadb-server-10.0`" == "" ]; then - if [ "$OS" == "debian" ]; then - add-apt-repository "deb http://mirror.netcologne.de/mariadb/repo/10.0/debian $OSBRANCH main" - RUNUPDATE=1 - elif [ "$OS" == "ubuntu" ]; then - add-apt-repository "deb http://mirror.netcologne.de/mariadb/repo/10.0/ubuntu $OSBRANCH main" - RUNUPDATE=1 - fi - fi - fi - - if [ "$OS" == "debian" -a "$DOTDEB" == "Yes" ]; then - echo "Package: *" > /etc/apt/preferences.d/mariadb.pref - echo "Pin: origin mirror.netcologne.de" >> /etc/apt/preferences.d/mariadb.pref - echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/mariadb.pref - RUNUPDATE=1 - fi - - if [ "$RUNUPDATE" == "1" ]; then - apt-get update - fi - - if ([ "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "8.0" -o "$OS" == "ubuntu" ] && [ "`grep '/mariadb/' /etc/apt/sources.list`" == "" ]); then - apt-get install mariadb-server mariadb-client mysql-common -y - else - apt-get install mariadb-server mariadb-client mariadb-common -y - fi - fi - - if [ "$SQL" == "MySQL" -o "$SQL" == "MariaDB" ]; then - - if [ "$INSTALL" == "WR" -o "$INSTALL" == "MY" ]; then - - cyanMessage " " - cyanMessage "Is Easy-WI installed on a different server." - - OPTIONS=("Yes" "No" "Quit") - select EXTERNAL_INSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - cyanMessage " " - okAndSleep "Securing MySQL by running \"mysql_secure_installation\" commands." - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.user WHERE User=''" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "FLUSH PRIVILEGES" 2> /dev/null - fi - - if [ "$EXTERNAL_INSTALL" == "Yes" ]; then - - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "GRANT USAGE ON *.* TO 'root'@'' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "UPDATE mysql.user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y' WHERE User='root' AND Host=''" 2> /dev/null - - if [ "$LOCAL_IP" == "" ]; then - - cyanMessage " " - cyanMessage "Could not detect local IP. Please specify which to use." - read LOCAL_IP - fi - - if [ "$LOCAL_IP" != "" -a -f /etc/mysql/my.cnf ]; then - if [ "`grep 'bind-address' /etc/mysql/my.cnf`" ]; then - sed -i "s/bind-address.*/bind-address = 0.0.0.0/g" /etc/mysql/my.cnf - else - echo "bind-address = 0.0.0.0" >> /etc/mysql/my.cnf - fi - fi - fi - - MYSQL_VERSION=`mysql -V | awk {'print $5'} | tr -d ,` - - if [ "`grep -E 'key_buffer[[:space:]]*=' /etc/mysql/my.cnf`" != "" -a "printf "${MYSQL_VERSION}\n5.5" | sort -V | tail -n 1" != 5.5 ]; then - sed -i "s/key_buffer[[:space:]]*=/key_buffer_size = /g" /etc/mysql/my.cnf - fi - - /etc/init.d/mysql restart - - if [ "$INSTALL" == "EW" -a "`ps ax | grep mysql | grep -v grep`" == "" ]; then - cyanMessage " " - errorAndExit "Error: No SQL server running but required for Webpanel installation." - fi - - if [ "$INSTALL" == "EW" ]; then - - okAndSleep "Please note that Easy-Wi will install required PHP packages." - PHPINSTALL="Yes" - - elif [ "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Install/Update PHP?" - cyanMessage "Select \"None\" in case this server should host only Fastdownload webspace." - - OPTIONS=("Yes" "No" "None" "Quit") - select PHPINSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$PHPINSTALL" == "Yes" ]; then - - USE_PHP_VERSION='5' - - if [ "$OS" == "ubuntu" -a "`printf "${OSVERSION}\n16.03" | sort -V | tail -n 1`" != "16.03" ]; then - USE_PHP_VERSION='7.0' - fi - - if [ "$OS" == "debian" -a "$DOTDEB" == "Yes" ]; then - - cyanMessage " " - - if [ "$OSBRANCH" == "wheezy" ]; then - - cyanMessage "Which PHP version should be used?" - - OPTIONS=("5.4" "5.5", "5.6", "5.6 Zend thread safety" "Quit") - select DOTDEBPHPUPGRADE in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4 ) break;; - 5 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$DOTDEBPHPUPGRADE" == "5.5" -a "`grep 'wheezy-php55' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php55 all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php55 all" - elif [ "$DOTDEBPHPUPGRADE" == "5.6" -a "`grep 'wheezy-php56' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php56 all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php56 all" - elif [ "$DOTDEBPHPUPGRADE" == "5.6 Zend thread safety" -a "`grep 'wheezy-php56-zts' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php56-zts all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php56-zts all" - fi - - elif [ "$OSBRANCH" == "squeeze" -a "`grep 'squeeze-php54' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org squeeze-php54 all" - add-apt-repository "deb-src http://packages.dotdeb.org squeeze-php54 all" - fi - - if [ "$DOTDEBPHPUPGRADE" == "Yes" ]; then - apt-get update - apt-get upgrade -y && apt-get dist-upgrade -y - fi - fi - - checkInstall php${USE_PHP_VERSION}-common - checkInstall php${USE_PHP_VERSION}-curl - checkInstall php${USE_PHP_VERSION}-gd - checkInstall php${USE_PHP_VERSION}-mcrypt - checkInstall php${USE_PHP_VERSION}-mysql - checkInstall php${USE_PHP_VERSION}-cli - - if [ "$WEBSERVER" == "Nginx" -o "$WEBSERVER" == "Lighttpd" ]; then - - checkInstall php${USE_PHP_VERSION}-fpm - - if [ "$WEBSERVER" == "Lighttpd" ]; then - lighttpd-enable-mod fastcgi - lighttpd-enable-mod fastcgi-php - fi - - makeDir /home/$MASTERUSER/fpm-pool.d/ - sed -i "s/include=\/etc\/php5\/fpm\/pool.d\/\*.conf/include=\/home\/$MASTERUSER\/fpm-pool.d\/\*.conf/g" /etc/php5/fpm/php-fpm.conf - sed -i "s/include=\/etc\/php/7.0\/fpm\/pool.d\/\*.conf/include=\/home\/$MASTERUSER\/fpm-pool.d\/\*.conf/g" /etc/php/7.0/fpm/php-fpm.conf - - elif [ "$WEBSERVER" == "Apache" ]; then - checkInstall apache2-mpm-itk - checkInstall libapache2-mpm-itk - checkInstall libapache2-mod-php${USE_PHP_VERSION} - checkInstall php${USE_PHP_VERSION} - a2enmod php${USE_PHP_VERSION} - fi - - #In case of php 7 the socket is different - PHP_VERSION=`php -v | grep -E '^PHP' | awk '{print $2}' | awk -F '.' '{print $1}'` - PHP_SOCKET="/var/run/php${PHP_VERSION}-fpm-${FILE_NAME}.sock" - fi -fi - -if ([ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ] && [ "`grep '/bin/false' /etc/shells`" == "" ]); then - echo "/bin/false" >> /etc/shells -fi - -if [ "$INSTALL" != "VS" -a "$INSTALL" != "EW" -a "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Install/Update ProFTPD?" - - OPTIONS=("Yes" "No" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Yes" ]; then - - echo "proftpd-basic shared/proftpd/inetd_or_standalone select standalone" | debconf-set-selections - apt-get install proftpd -y - - if [ -f /etc/proftpd/modules.conf ]; then - - backUpFile /etc/proftpd/modules.conf - - sed -i 's/.*LoadModule mod_tls_memcache.c.*/#LoadModule mod_tls_memcache.c/g' /etc/proftpd/modules.conf - fi - - backUpFile /etc/proftpd/proftpd.conf - - sed -i 's/.*UseIPv6.*/UseIPv6 off/g' /etc/proftpd/proftpd.conf - sed -i 's/#.*DefaultRoot.*~/DefaultRoot ~/g' /etc/proftpd/proftpd.conf - sed -i 's/# RequireValidShell.*/RequireValidShell on/g' /etc/proftpd/proftpd.conf - - if [ -f /etc/proftpd/proftpd.conf -a "$INSTALL" != "GS" ]; then - - sed -i 's/Umask.*/Umask 037 027/g' /etc/proftpd/proftpd.conf - - elif [ -f /etc/proftpd/proftpd.conf -a "$INSTALL" == "GS" ]; then - - sed -i 's/Umask.*/Umask 077 077/g' /etc/proftpd/proftpd.conf - - cyanMessage " " - cyanMessage "Install/Update ProFTPD Rules?" - - OPTIONS=("Yes" "No" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Yes" -a "`grep '' /etc/proftpd/proftpd.conf`" == "" -a ! -f "/etc/proftpd/conf.d/easy-wi.conf" ]; then - - makeDir /etc/proftpd/conf.d/ - chmod 755 /etc/proftpd/conf.d/ - - echo " - - HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on - - DenyAll - -" > /etc/proftpd/conf.d/easy-wi.conf - echo "" >> /etc/proftpd/conf.d/easy-wi.conf - echo " HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - HideNoAccess on - Umask 137 027 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 177 077 - - AllowAll - - - - HideFiles (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on -" >> /etc/proftpd/conf.d/easy-wi.conf - - - GAMES=("ark" "arma3" "bukkit" "hexxit" "mc" "mtasa" "projectcars" "rust" "samp" "spigot" "teeworlds" "tekkit" "tekkit-classic") - - for GAME in ${GAMES[@]}; do - echo " - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - - GAME_MODS=("csgo" "cstrike" "czero" "orangebox" "dod" "garrysmod") - - for GAME_MOD in ${GAME_MODS[@]}; do - echo " - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - - FOLDERS=("addons" "cfg" "maps") - - for FOLDER in ${FOLDERS[@]}; do - echo " - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - fi - fi - - if [ -f /etc/init.d/proftpd ]; then - service proftpd restart - fi - fi -fi - -if [ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ]; then - - cyanMessage " " - cyanMessage "Install Quota?" - - OPTIONS=("Yes" "No" "Quit") - select QUOTAINSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$QUOTAINSTALL" == "Yes" ]; then - - checkInstall quota - - cyanMessage " " - cyanMessage " " - removeIfExists /root/tempfstab - removeIfExists /root/tempmountpoints - - cat /etc/fstab | while read LINE; do - if [[ `echo $LINE | grep '/' | egrep -v '#|boot|proc|swap|floppy|cdrom|usrquota|usrjquota|/sys|/shm|/pts'` ]]; then - CURRENTOPTIONS=`echo $LINE | awk '{print $4}'` - echo $LINE | sed "s/$CURRENTOPTIONS/$CURRENTOPTIONS,usrjquota=aquota.user,jqfmt=vfsv0/g" >> /root/tempfstab - echo $LINE | awk '{print $2}' >> /root/tempmountpoints - else - echo $LINE >> /root/tempfstab - fi - done - - cat /root/tempfstab - - cyanMessage " " - cyanMessage " " - cyanMessage "Please check above output and confirm it is correct. On confirmation the current /etc/fstab will be replaced in order to activate Quotas!" - - OPTIONS=("Yes" "No" "Quit") - select QUOTAFSTAB in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$QUOTAFSTAB" == "Yes" ]; then - backUpFile /etc/fstab - mv /root/tempfstab /etc/fstab - fi - - removeIfExists /root/tempfstab - removeIfExists /aquota.user - touch /aquota.user - chmod 600 /aquota.user - - if [ -f /root/tempmountpoints ]; then - - cat /root/tempmountpoints | while read LINE; do - - quotaoff -ugv $LINE - - removeIfExists $LINE/aquota.user - - okAndSleep "Remounting $LINE" - mount -o remount $LINE - - quotacheck -vumc $LINE - quotaon -uv $LINE - done - - removeIfExists /root/tempmountpoints - fi - fi -fi - -if [ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ]; then - - if [ "$WEBSERVER" == "Nginx" ]; then - - backUpFile /etc/nginx/nginx.conf - - if [ "`grep '/home/$MASTERUSER/sites-enabled/' /etc/nginx/nginx.conf`" == "" ]; then - sed -i "\/etc\/nginx\/sites-enabled\/\*;/a \ \ \ \ \ \ \ \ include \/home\/$MASTERUSER\/sites-enabled\/\*;" /etc/nginx/nginx.conf - fi - - elif [ "$WEBSERVER" == "Lighttpd" ]; then - - backUpFile /etc/lighttpd/lighttpd.conf - echo "include_shell \"find /home/$MASTERUSER/sites-enabled/ -maxdepth 1 -type f -exec cat {} \;\"" >> /etc/lighttpd/lighttpd.conf - - elif [ "$WEBSERVER" == "Apache" ]; then - - backUpFile /etc/apache2/apache2.conf - - if [ "`grep 'ServerName localhost' /etc/apache2/apache2.conf`" == "" ]; then - echo '# Added to prevent error message Could not reliably determine the servers fully qualified domain name' >> /etc/apache2/apache2.conf - echo 'ServerName localhost' >> /etc/apache2/apache2.conf - fi - - APACHE_VERSION=`apache2 -v | grep 'Server version'` - - if [ "`grep '/home/$MASTERUSER/sites-enabled/' /etc/apache2/apache2.conf`" == "" ]; then - if [[ $APACHE_VERSION =~ .*Apache/2.2.* ]]; then - sed -i "/Include sites-enabled\//a Include \/home\/$MASTERUSER\/sites-enabled\/" /etc/apache2/apache2.conf - sed -i "/Include \/etc\/apache2\/sites-enabled\//a \/home\/$MASTERUSER\/sites-enabled\/" /etc/apache2/apache2.conf - else - sed -i "/IncludeOptional sites-enabled\//a IncludeOptional \/home\/$MASTERUSER\/sites-enabled\/*.conf" /etc/apache2/apache2.conf - sed -i "/IncludeOptional \/etc\/apache2\/sites-enabled\//a IncludeOptional \/home\/$MASTERUSER\/sites-enabled\/*.conf" /etc/apache2/apache2.conf - fi - fi - - okAndSleep "Activating Apache mod_rewrite module." - a2enmod rewrite - a2enmod version 2> /dev/null - fi - - #TODO: Logrotate -fi - -# No direct root access for masteruser. Only limited access through sudo -if [ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ]; then - - checkInstall sudo - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERADD`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERADD" >> /etc/sudoers - fi - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERMOD`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERMOD" >> /etc/sudoers - fi - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERDEL`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERDEL" >> /etc/sudoers - fi - - if [ "$QUOTAINSTALL" == "Yes" -a -f /etc/sudoers ]; then - if [ "`grep $MASTERUSER /etc/sudoers | grep setquota`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: `which setquota`" >> /etc/sudoers - fi - - if [ "`grep $MASTERUSER /etc/sudoers | grep repquota`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: `which repquota`" >> /etc/sudoers - fi - fi - - if [ "$INSTALL" == "GS" -a -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep temp`" == "" ]; then - echo "$MASTERUSER ALL = (ALL, !root:easywi) NOPASSWD: /home/$MASTERUSER/temp/*.sh" >> /etc/sudoers - fi - - if [ "$WEBSERVER" == "Nginx" ]; then - HTTPDBIN=`which nginx` - HTTPDSCRIPT="/etc/init.d/nginx" - elif [ "$WEBSERVER" == "Lighttpd" ]; then - HTTPDBIN=`which lighttpd` - HTTPDSCRIPT="/etc/init.d/lighttpd" - elif [ "$WEBSERVER" == "Apache" ]; then - HTTPDBIN=`which apache2` - HTTPDSCRIPT="/etc/init.d/apache2" - fi - - if [ "$HTTPDBIN" != "" -a -f /etc/sudoers ]; then - if [ "`grep $MASTERUSER /etc/sudoers | grep $HTTPDBIN`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $HTTPDBIN" >> /etc/sudoers - fi - - if [ "`grep $MASTERUSER /etc/sudoers | grep $HTTPDSCRIPT`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $HTTPDSCRIPT" >> /etc/sudoers - fi - fi -fi - -if [ "$INSTALL" == "WR" ]; then - - chown -R $MASTERUSER:$WEBGROUPID /home/$MASTERUSER/ - - greenMessage "Following data need to be configured at the easy-wi.com panel:" - - greenMessage "The path to the folder \"sites-enabled\" is:" - greenMessage "/home/$MASTERUSER/sites-enabled/" - - greenMessage "The useradd command is:" - greenMessage "sudo $USERADD %cmd%" - - greenMessage "The usermod command is:" - greenMessage "sudo $USERMOD %cmd%" - - greenMessage "The userdel command is:" - greenMessage "sudo $USERDEL %cmd%" - - greenMessage "The HTTPD restart command is:" - greenMessage "sudo $HTTPDSCRIPT reload" -fi - -if ([ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ] && [ "$QUOTAINSTALL" == "Yes" ]); then - greenMessage "The setquota command is:" - greenMessage "sudo `which setquota` %cmd%" - greenMessage "The repquota command is:" - greenMessage "sudo `which repquota` %cmd%" -fi - -if [ "$INSTALL" == "GS" ]; then - - cyanMessage " " - cyanMessage "Java JRE will be required for running Minecraft and its mods. Shall it be installed?" - OPTIONS=("Yes" "No" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Yes" ]; then - checkInstall default-jre - fi - - okAndSleep "Creating folders and files" - CREATEDIRS=("conf" "fdl_data/hl2" "logs" "masteraddons" "mastermaps" "masterserver" "temp") - for CREATEDIR in ${CREATEDIRS[@]}; do - greenMessage "Adding dir: /home/$MASTERUSER/$CREATEDIR" - makeDir /home/$MASTERUSER/$CREATEDIR - done - - LOGFILES=("addons" "hl2" "server" "fdl" "update" "fdl-hl2") - for LOGFILE in ${LOGFILES[@]}; do - touch "/home/$MASTERUSER/logs/$LOGFILE.log" - done - chmod 660 /home/$MASTERUSER/logs/*.log - - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER/ - chmod -R 750 /home/$MASTERUSER/ - chmod -R 770 /home/$MASTERUSER/logs/ /home/$MASTERUSER/temp/ /home/$MASTERUSER/fdl_data/ - - if [ "$OS" == "debian" -a "`uname -m`" == "x86_64" -a "`cat /etc/debian_version | grep '6.'`" == "" ]; then - dpkg --add-architecture i386 - fi - - if [ "$OS" == "debian" -o "$OS" == "ubuntu" ]; then - - okAndSleep "Installing required packages wput screen bzip2 sudo rsync zip unzip" - apt-get install wput screen bzip2 sudo rsync zip unzip -y - - if [ "`uname -m`" == "x86_64" ]; then - - okAndSleep "Installing 32bit support for 64bit systems." - - if ([ "$OS" == "ubuntu" ] || [ "$OS" == "debian" -a "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "$OSVERSION" ]); then - apt-get install zlib1g lib32z1 lib32gcc1 lib32readline5 lib32ncursesw5 -y - apt-get install lib32stdc++6 -y - apt-get install lib64stdc++6 -y - apt-get install libstdc++6 -y - apt-get install libgcc1:i386 -y - apt-get install libreadline5:i386 -y - apt-get install libncursesw5:i386 -y - apt-get install zlib1g:i386 -y - else - apt-get install ia32-libs lib32readline5 lib32ncursesw5 lib32stdc++6 -y - fi - else - apt-get install libreadline5 libncursesw5 -y - fi - fi - - okAndSleep "Downloading SteamCmd" - - cd /home/$MASTERUSER/masterserver - makeDir /home/$MASTERUSER/masterserver/steamCMD/ - cd /home/$MASTERUSER/masterserver/steamCMD/ - curl --remote-name http://media.steampowered.com/client/steamcmd_linux.tar.gz - - if [ -f steamcmd_linux.tar.gz ]; then - tar xfvz steamcmd_linux.tar.gz - removeIfExists steamcmd_linux.tar.gz - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER/masterserver/steamCMD - su -c "./steamcmd.sh +login anonymous +quit" $MASTERUSER - if [ -f /home/$MASTERUSER/masterserver/steamCMD/linux32/steamclient.so ]; then - su -c "mkdir -p ~/.steam/sdk32/" $MASTERUSER - su -c "chmod 750 -R ~/.steam/" $MASTERUSER - su -c "ln -s ~/masterserver/steamCMD/linux32/steamclient.so ~/.steam/sdk32/steamclient.so" $MASTERUSER - fi - fi - - chown -R $INSTALLMASTER:$INSTALLMASTER /home/$INSTALLMASTER - - if [ -f /etc/crontab -a "`grep 'Minecraft can easily produce 1GB' /etc/crontab`" == "" ]; then - - if ionice -c3 true 2>/dev/null; then - IONICE="ionice -n 7 " - fi - - echo "#Minecraft can easily produce 1GB+ logs within one hour" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 ionice -n 7 find /home/*/server/*/*/ -maxdepth 2 -type f -name \"screenlog.0\" -size +100M -delete" >> /etc/crontab - echo "# Even sudo /usr/sbin/deluser --remove-all-files is used some data remain from time to time" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /home/ -maxdepth 2 -type d -nouser -delete" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /home/*/fdl_data/ /home/*/temp/ /tmp/ /var/run/screen/ -nouser -print0 | xargs -0 rm -rf" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /var/run/screen/ -maxdepth 1 -type d -nouser -print0 | xargs -0 rm -rf" >> /etc/crontab - - service cron restart - fi -fi - -if [ "$INSTALL" == "EW" ]; then - - makeDir /home/$MASTERUSER/fpm-pool.d/ - - if [ -f /home/easywi_web/htdocs/serverallocation.php ]; then - - cyanMessage " " - cyanMessage "There is already an existing installation. Should it be removed?" - OPTIONS=("Yes" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - rm -rf /home/easywi_web/htdocs/* - fi - - if [ "`id easywi_web 2> /dev/null`" == "" -a ! -d /home/easywi_web ]; then - $USERADD -md /home/easywi_web -g www-data -s /bin/bash -k /home/$MASTERUSER/skel/ easywi_web - elif [ "`id easywi_web 2> /dev/null`" == "" -a -d /home/easywi_web ]; then - $USERADD -d /home/easywi_web -g www-data -s /bin/bash easywi_web - fi - - makeDir /home/easywi_web/htdocs/ - makeDir /home/easywi_web/logs/ - makeDir /home/easywi_web/tmp/ - makeDir /home/easywi_web/session/ - chown -R easywi_web:$WEBGROUPID /home/easywi_web/htdocs/ /home/easywi_web/logs/ /home/easywi_web/tmp/ /home/easywi_web/session/ - - if [ "`id easywi_web 2> /dev/null`" == "" ]; then - errorAndExit "Web user easywi_web does not exists! Exiting now!" - fi - - if [ ! -d /home/easywi_web/htdocs ]; then - errorAndExit "No home/htdocs dir created! Exiting now!" - fi - - checkInstall unzip - - cd /home/easywi_web/htdocs/ - - okAndSleep "Downloading latest Easy-WI stable." - curl https://easy-wi.com/uk/downloads/get/3/ -o web.zip - - if [ ! -f web.zip ]; then - errorAndExit "Can not download Easy-WI. Aborting!" - fi - - okAndSleep "Unpack zipped Easy-WI archive." - unzip -u web.zip >/dev/null 2>&1 - removeIfExists web.zip - - find /home/easywi_web/ -type f -print0 | xargs -0 chmod 640 - find /home/easywi_web/ -mindepth 1 -type d -print0 | xargs -0 chmod 750 - - chown -R easywi_web:www-data /home/easywi_web - - DB_PASSWORD=`< /dev/urandom tr -dc A-Za-z0-9 | head -c18` - - okAndSleep "Creating database easy_wi and connected user easy_wi" - mysql -uroot -p$MYSQL_ROOT_PASSWORD -Bse "CREATE DATABASE IF NOT EXISTS easy_wi; GRANT ALL ON easy_wi.* TO 'easy_wi'@'localhost' IDENTIFIED BY '$DB_PASSWORD'; FLUSH PRIVILEGES;" - - cyanMessage " " - cyanMessage "Secure Vhost with SSL? (recommended!)" - OPTIONS=("Yes" "No" "Quit") - select SSL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - FILE_NAME=${IP_DOMAIN//./_} - - if [ "$SSL" == "Yes" ]; then - - checkInstall openssl - - if [ "$WEBSERVER" == "Nginx" ]; then - SSL_DIR=/etc/nginx/ssl - elif [ "$WEBSERVER" == "Apache" ]; then - SSL_DIR=/etc/apache2/ssl - fi - - makeDir $SSL_DIR - - cyanMessage " " - okAndSleep "Creating a self-signed SSL certificate." - openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $SSL_DIR/$FILE_NAME.key -out $SSL_DIR/$FILE_NAME.crt -subj "/C=/ST=/L=/O=/OU=/CN=$IP_DOMAIN" - fi - - if [ "$WEBSERVER" == "Nginx" -o "$WEBSERVER" == "Lighttpd" ]; then - - FILE_NAME_POOL=/home/$MASTERUSER/fpm-pool.d/$FILE_NAME.conf - - echo "[$IP_DOMAIN]" > $FILE_NAME_POOL - echo "user = easywi_web" >> $FILE_NAME_POOL - echo "group = www-data" >> $FILE_NAME_POOL - echo "listen = ${PHP_SOCKET}" >> $FILE_NAME_POOL - echo "listen.owner = easywi_web" >> $FILE_NAME_POOL - echo "listen.group = www-data" >> $FILE_NAME_POOL - echo "pm = dynamic" >> $FILE_NAME_POOL - echo "pm.max_children = 1" >> $FILE_NAME_POOL - echo "pm.start_servers = 1" >> $FILE_NAME_POOL - echo "pm.min_spare_servers = 1" >> $FILE_NAME_POOL - echo "pm.max_spare_servers = 1" >> $FILE_NAME_POOL - echo "pm.max_requests = 500" >> $FILE_NAME_POOL - echo "chdir = /" >> $FILE_NAME_POOL - echo "access.log = /home/easywi_web/logs/fpm-access.log" >> $FILE_NAME_POOL - echo "php_flag[display_errors] = off" >> $FILE_NAME_POOL - echo "php_admin_flag[log_errors] = on" >> $FILE_NAME_POOL - echo "php_admin_value[error_log] = /home/easywi_web/logs/fpm-error.log" >> $FILE_NAME_POOL - echo "php_admin_value[memory_limit] = 32M" >> $FILE_NAME_POOL - echo "php_admin_value[open_basedir] = /home/easywi_web/htdocs/:/home/easywi_web/tmp/" >> $FILE_NAME_POOL - echo "php_admin_value[upload_tmp_dir] = /home/easywi_web/tmp" >> $FILE_NAME_POOL - echo "php_admin_value[session.save_path] = /home/easywi_web/session" >> $FILE_NAME_POOL - - chown $MASTERUSER:www-data $FILE_NAME_POOL - fi - - FILE_NAME_VHOST=/home/$MASTERUSER/sites-enabled/$FILE_NAME - - if [ "$WEBSERVER" == "Nginx" ]; then - echo 'server {' > $FILE_NAME_VHOST - echo ' listen 80;' >> $FILE_NAME_VHOST - - if [ "$SSL" == "Yes" ]; then - - echo " server_name $IP_DOMAIN;" >> $FILE_NAME_VHOST - echo " return 301 https://$IP_DOMAIN"'$request_uri;' >> $FILE_NAME_VHOST - echo '}' >> $FILE_NAME_VHOST - - backUpFile /etc/nginx/nginx.conf - - if [ "`grep 'ssl_ecdh_curve secp384r1;' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_ecdh_curve secp384r1;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_session_cache' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_session_cache shared:SSL:10m;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_session_timeout' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_session_timeout 10m;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_ciphers' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_ciphers EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:!MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL;' /etc/nginx/nginx.conf - fi - - echo 'server {' >> $FILE_NAME_VHOST - echo ' listen 443 ssl;' >> $FILE_NAME_VHOST - echo " ssl_certificate /etc/nginx/ssl/$FILE_NAME.crt;" >> $FILE_NAME_VHOST - echo " ssl_certificate_key /etc/nginx/ssl/$FILE_NAME.key;" >> $FILE_NAME_VHOST - fi - - echo ' root /home/easywi_web/htdocs/;' >> $FILE_NAME_VHOST - echo ' index index.html index.htm index.php;' >> $FILE_NAME_VHOST - echo " server_name $IP_DOMAIN;" >> $FILE_NAME_VHOST - echo ' location ~ /(keys|stuff|template|languages|downloads|tmp) { deny all; }' >> $FILE_NAME_VHOST - echo ' location / {' >> $FILE_NAME_VHOST - echo ' try_files $uri $uri/ =404;' >> $FILE_NAME_VHOST - echo ' }' >> $FILE_NAME_VHOST - echo ' location ~ \.php$ {' >> $FILE_NAME_VHOST - echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> $FILE_NAME_VHOST - echo ' try_files $fastcgi_script_name =404;' >> $FILE_NAME_VHOST - echo ' set $path_info $fastcgi_path_info;' >> $FILE_NAME_VHOST - echo ' fastcgi_param PATH_INFO $path_info;' >> $FILE_NAME_VHOST - echo ' fastcgi_index index.php;' >> $FILE_NAME_VHOST - - if [ -f /etc/nginx/fastcgi.conf ]; then - echo ' include /etc/nginx/fastcgi.conf;' >> $FILE_NAME_VHOST - elif [ -f /etc/nginx/fastcgi_params ]; then - echo ' include /etc/nginx/fastcgi_params;' >> $FILE_NAME_VHOST - fi - - echo " fastcgi_pass unix:${PHP_SOCKET};" >> $FILE_NAME_VHOST - echo ' }' >> $FILE_NAME_VHOST - echo '}' >> $FILE_NAME_VHOST - - chown -R $MASTERUSER:$WEBGROUPID /home/$MASTERUSER/ - - okAndSleep "Restarting PHP-FPM and Nginx." - service php${USE_PHP_VERSION}-fpm restart - service nginx restart - - elif [ "$WEBSERVER" == "Apache" ]; then - - FILE_NAME_VHOST="$FILE_NAME_VHOST.conf" - - echo '' > $FILE_NAME_VHOST - echo " ServerName $IP_DOMAIN" >> $FILE_NAME_VHOST - echo " ServerAdmin info@$IP_DOMAIN" >> $FILE_NAME_VHOST - - if [ "$SSL" == "Yes" ]; then - - echo " Redirect permanent / https://$IP_DOMAIN/" >> $FILE_NAME_VHOST - echo '' >> $FILE_NAME_VHOST - - okAndSleep "Activating TLS/SSL related Apache modules." - a2enmod ssl - service apache2 restart - - echo '' >> $FILE_NAME_VHOST - echo " ServerName $IP_DOMAIN" >> $FILE_NAME_VHOST - echo ' SSLEngine on' >> $FILE_NAME_VHOST - echo " SSLCertificateFile /etc/apache2/ssl/$FILE_NAME.crt" >> $FILE_NAME_VHOST - echo " SSLCertificateKeyFile /etc/apache2/ssl/$FILE_NAME.key" >> $FILE_NAME_VHOST - - fi - - - echo ' DocumentRoot "/home/easywi_web/htdocs/"' >> $FILE_NAME_VHOST - echo ' ErrorLog "/home/easywi_web/logs/error.log"' >> $FILE_NAME_VHOST - echo ' CustomLog "/home/easywi_web/logs/access.log" common' >> $FILE_NAME_VHOST - echo ' DirectoryIndex index.php index.html' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' AssignUserId easywi_web www-data' >> $FILE_NAME_VHOST - echo ' MaxClientsVHost 50' >> $FILE_NAME_VHOST - echo ' NiceValue 10' >> $FILE_NAME_VHOST - echo ' php_admin_flag allow_url_include off' >> $FILE_NAME_VHOST - echo ' php_admin_flag display_errors off' >> $FILE_NAME_VHOST - echo ' php_admin_flag log_errors on' >> $FILE_NAME_VHOST - echo ' php_admin_flag mod_rewrite on' >> $FILE_NAME_VHOST - echo ' php_admin_value open_basedir "/home/easywi_web/htdocs/:/home/easywi_web/tmp"' >> $FILE_NAME_VHOST - echo ' php_admin_value session.save_path "/home/easywi_web/session"' >> $FILE_NAME_VHOST - echo ' php_admin_value upload_tmp_dir "/home/easywi_web/tmp"' >> $FILE_NAME_VHOST - echo ' php_admin_value upload_max_size 32M' >> $FILE_NAME_VHOST - echo ' php_admin_value memory_limit 32M' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Options -Indexes +FollowSymLinks +Includes' >> $FILE_NAME_VHOST - echo ' AllowOverride None' >> $FILE_NAME_VHOST - echo ' = 2.4>' >> $FILE_NAME_VHOST - echo ' Require all granted' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Order allow,deny' >> $FILE_NAME_VHOST - echo ' Allow from all' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' = 2.4>' >> $FILE_NAME_VHOST - echo ' Require all denied' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Order deny,allow' >> $FILE_NAME_VHOST - echo ' Deny from all' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo '' >> $FILE_NAME_VHOST - - okAndSleep "Restarting Apache2." - service apache2 restart - fi - - chown $MASTERUSER:www-data $FILE_NAME_VHOST - - if [ "`grep reboot.php /etc/crontab`" == "" ]; then - echo '0 */1 * * * easywi_web cd /home/easywi_web/htdocs && timeout 300 php ./reboot.php >/dev/null 2>&1 -0 */1 * * * easywi_web cd /home/easywi_web/htdocs && timeout 300 php ./reboot.php >/dev/null 2>&1 -*/5 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./statuscheck.php >/dev/null 2>&1 -*/1 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./startupdates.php >/dev/null 2>&1 -*/5 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./jobs.php >/dev/null 2>&1 -*/10 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./cloud.php >/dev/null 2>&1' >> /etc/crontab - fi - - service cron restart -fi - -if [ "$INSTALL" == "VS" ]; then - - ps -u $MASTERUSER | grep ts3server | awk '{print $1}' | while read PID; do - kill $PID - done - - if [ -f /home/$MASTERUSER/ts3server_startscript.sh ]; then - rm -rf /home/$MASTERUSER/* - fi - - makeDir /home/$MASTERUSER/ - chmod 750 /home/$MASTERUSER/ - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER - - cd /home/$MASTERUSER/ - - okAndSleep "Downloading TS3 server files." - su -c "curl $DOWNLOAD_URL -o teamspeak3-server.tar.bz2" $MASTERUSER - - if [ ! -f teamspeak3-server.tar.bz2 ]; then - errorAndExit "Download failed! Exiting now!" - fi - - okAndSleep "Extracting TS3 server files." - su -c "tar -xf teamspeak3-server.tar.bz2 --strip-components=1" $MASTERUSER - - removeIfExists teamspeak3-server.tar.bz2 - - QUERY_WHITLIST_TXT=/home/$MASTERUSER/query_ip_whitelist.txt - - if [ ! -f $QUERY_WHITLIST_TXT ]; then - touch $QUERY_WHITLIST_TXT - chown $MASTERUSER:$MASTERUSER $QUERY_WHITLIST_TXT - fi - - if [ -f $QUERY_WHITLIST_TXT ]; then - - if [ "`grep '127.0.0.1' $QUERY_WHITLIST_TXT`" == "" ]; then - echo "127.0.0.1" >> $QUERY_WHITLIST_TXT - fi - - if [ "$LOCAL_IP" != "" ]; then - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $LOCAL_IP`" != "" -a "`grep $LOCAL_IP $QUERY_WHITLIST_TXT`" == "" ]; then - echo $LOCAL_IP >> $QUERY_WHITLIST_TXT - fi - fi - - cyanMessage " " - cyanMessage "Please specify the IPv4 address of the Easy-WI web panel." - read IP_ADDRESS - - if [ "$IP_ADDRESS" != "" ]; then - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $IP_ADDRESS`" != "" -a "`grep $IP_ADDRESS $QUERY_WHITLIST_TXT`" == "" ]; then - echo $IP_ADDRESS >> $QUERY_WHITLIST_TXT - fi - fi - else - redMessage "Cannot edit the file $QUERY_WHITLIST_TXT, please maintain it manually." - fi - - QUERY_PASSWORD=`< /dev/urandom tr -dc A-Za-z0-9 | head -c12` - - greenMessage "Starting the TS3 server for the first time and shutting it down again as the password will be visible in the process tree." - su -c "./ts3server_startscript.sh start serveradmin_password=$QUERY_PASSWORD createinifile=1 inifile=ts3server.ini" $MASTERUSER - runSpinner 25 - su -c "./ts3server_startscript.sh stop" $MASTERUSER - - greenMessage "Starting the TS3 server permanently." - su -c "./ts3server_startscript.sh start inifile=ts3server.ini" $MASTERUSER -fi - -okAndSleep "Removing not needed packages." -apt-get autoremove -y - -if [ "$INSTALL" == "EW" ]; then - - if [ "$SSL" == "Yes" ]; then - PROTOCOL="https" - else - PROTOCOL="http" - fi - - greenMessage "Easy-WI Webpanel setup is done regarding architecture. Please open $PROTOCOL://$IP_DOMAIN/install/install.php and complete the installation dialog." - greenMessage "DB user and table name are \"easy_wi\". The password is \"$DB_PASSWORD\"." - -elif [ "$INSTALL" == "GS" ]; then - greenMessage "Gameserver Root setup is done. Please enter the above data at the webpanel at \"App/Game Master > Overview > Add\"." -elif [ "$INSTALL" == "VS" ]; then - greenMessage "Teamspeak 3 setup is done. TS3 Query password is $QUERY_PASSWORD. Please enter the data at the webpanel at \"Voiceserver > Master > Add\"." -elif [ "$INSTALL" == "WR" ]; then - greenMessage "Webspace Root setup is done. Please enter the above data at the webpanel at \"Webspace > Master > Add\"." -fi - -if ([ "$INSTALL" == "MY" ] || [ "$INSTALL" == "WR" -a "$SQL" != "None" ]); then - greenMessage "MySQL Root setup is done. Please enter the server at the webpanel at \"MySQL > Master > Add\"." -fi - -exit 0 diff --git a/server/easy-wi_install_it.sh b/server/easy-wi_install_it.sh deleted file mode 100644 index 88e89503..00000000 --- a/server/easy-wi_install_it.sh +++ /dev/null @@ -1,1593 +0,0 @@ -#!/bin/bash - -# Author: Ulrich Block -# -# This file is part of Easy-WI. -# -# Easy-WI is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Easy-WI is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Easy-WI. If not, see . -# -# Diese Datei ist Teil von Easy-WI. -# -# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen -# der GNU General Public License, wie von der Free Software Foundation, -# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren -# veroeffentlichten Version, weiterverbreiten und/oder modifizieren. -# -# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber -# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite -# Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. -# Siehe die GNU General Public License fuer weitere Details. -# -# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -# Programm erhalten haben. Wenn nicht, siehe . - -function greenMessage { - echo -e "\\033[32;1m${@}\033[0m" -} - -function cyanMessage { - echo -e "\\033[36;1m${@}\033[0m" -} - -function redMessage { - echo -e "\\033[31;1m${@}\033[0m" -} - -function yellowMessage { - echo -e "\\033[33;1m${@}\033[0m" -} - -function errorAndQuit { - errorAndExit "Exit now!" -} - -function errorAndExit { - redMessage ${@} - exit 0 -} - -function errorAndContinue { - redMessage "Invalid option." - continue -} - -function removeIfExists { - if [ "$1" != "" -a -f "$1" ]; then - rm -f $1 - fi -} - -function runSpinner { - - SPINNER=("-" "\\" "|" "/") - - for SEQUENCE in `seq 1 $1`; do - for I in "${SPINNER[@]}"; do - echo -ne "\b$I" - sleep 0.1 - done - done -} - -function okAndSleep { - greenMessage $1 - sleep 1 -} - -function makeDir { - if [ "$1" != "" -a ! -d $1 ]; then - mkdir -p $1 - fi -} - -function backUpFile { - if [ ! -f "$1.easy-install.backup" ]; then - cp "$1" "$1.easy-install.backup" - fi -} - -function checkInstall { - if [ "`dpkg-query -s $1 2>/dev/null`" == "" ]; then - okAndSleep "Installing package $1" - apt-get install -y $1 - fi -} - -INSTALLER_VERSION="1.6" -OS="" -USERADD=`which useradd` -USERMOD=`which usermod` -USERDEL=`which userdel` -GROUPADD=`which groupadd` -MACHINE=`uname -m` -LOCAL_IP=`ip route get 8.8.8.8 | awk '{print $NF; exit}'` - -if [ "$LOCAL_IP" == "" ]; then - HOST_NAME=`hostname -f | awk '{print tolower($0)}'` -else - HOST_NAME=`getent hosts $LOCAL_IP | awk '{print tolower($2)}' | head -n 1` -fi - -cyanMessage "Controllando per l'utima versione dell'installer" -LATEST_VERSION=`wget -q --timeout=60 -O - http://l.easy-wi.com/installer_version.php | sed 's/^\xef\xbb\xbf//g'` - -if [ "`printf "${LATEST_VERSION}\n${INSTALLER_VERSION}" | sort -V | tail -n 1`" != "$INSTALLER_VERSION" ]; then - errorAndExit "Stai utilizzado la versione ${INSTALLER_VERSION}. Perfavore effttua l'upgrade alla versione ${LATEST_VERSION} e riprova." -else - okAndSleep "Stai utilizzando la versione aggiornata dell'installer ${INSTALLER_VERSION}." -fi - -# We need to be root to install and update -if [ "`id -u`" != "0" ]; then - cyanMessage "Per poter proseguire con l'installazione è necessario utilizzare l'account di root" - su - -fi - -if [ "`id -u`" != "0" ]; then - errorAndExit "Ancora non si hanno i privilegi di root, abortendo" -fi - -# Debian and its derivatives store their version at /etc/debian_version -if [ -f /etc/debian_version ]; then - - cyanMessage " " - okAndSleep "Effettuare l'update dei pacchetti di sistema all'ultima versione? Richiesto, alcune dipendenze potrbbero essere mancanti!" - - OPTIONS=("Si" "Esci") - select UPDATE_UPGRADE_SYSTEM in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y - - checkInstall curl - checkInstall debconf-utils - checkInstall lsb-release - - OS=`lsb_release -i 2> /dev/null | grep 'Distributor' | awk '{print tolower($3)}'` - OSVERSION=`lsb_release -r 2> /dev/null | grep 'Release' | awk '{print $2}'` - OSBRANCH=`lsb_release -c 2> /dev/null | grep 'Codename' | awk '{print $2}'` -fi - -if [ "$OS" == "" ]; then - errorAndExit "Errore: Non sono in grado di stabilire il sistema operativo in uso. Attualmente sono supportati solo Debian ed Ubuntu. Abortendo!" -else - okAndSleep "OS rilevato: $OS" -fi - -if [ "$OSBRANCH" == "" ]; then - errorAndExit "Errore: Non posso rilevare nessuna distro di un OS. Abortendo" -else - okAndSleep "Distro rilevata: $OSBRANCH" -fi - -cyanMessage " " -cyanMessage "Cosa dovrebbe essere installato/preparato?" - -OPTIONS=("Server principale di gioco" "Server principale di voce" "Pannello web Easy-WI" "Server principale di spazio web" "MySQL" "Esci") -select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4|5 ) break;; - 6 ) errorAndQuit;; - *) errorAndContinue;; - esac -done - -if [ "$OPTION" == "Easy-WI Webpanel" ]; then - INSTALL="EW" -elif [ "$OPTION" == "Gameserver Root" ]; then - INSTALL="GS" -elif [ "$OPTION" == "Voicemaster" ]; then - INSTALL="VS" -elif [ "$OPTION" == "Webspace Root" ]; then - INSTALL="WR" -elif [ "$OPTION" == "MySQL" ]; then - INSTALL="MY" -fi - -OTHER_PANEL="" - -if [ "$INSTALL" != "VS" ]; then - if [ -f /etc/init.d/psa ]; then - OTHER_PANEL="Plesk" - elif [ -f /usr/local/vesta/bin/v-change-user-password ]; then - OTHER_PANEL="VestaCP" - elif [ -d /root/confixx ]; then - OTHER_PANEL="Confixx" - elif [ -d /var/www/froxlor ]; then - OTHER_PANEL="Froxlor" - elif [ -d /etc/imscp ]; then - OTHER_PANEL="i-MSCP" - elif [ -d /usr/local/ispconfig ]; then - OTHER_PANEL="ISPConfig" - elif [ -d /var/cpanel ]; then - OTHER_PANEL="cPanel" - elif [ -d /usr/local/directadmin ]; then - OTHER_PANEL="DirectAdmin" - fi -fi - -if [ "$OTHER_PANEL" != "" ]; then - if [ "$INSTALL" == "GS" ]; then - yellowMessage " " - yellowMessage "Attenzione, una installazione del pannello di controllo $OTHER_PANEL è stata rilevata." - yellowMessage "Se continuerai l'installazione potrebbe interrompersi danneggiando $OTHER_PANEL o alcune parti dell'Easy-WI potrebbero non funzionare." - OPTIONS=("Continua" "Esci") - select UPDATE_UPGRADE_SYSTEM in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - else - errorAndExit "Annullando onde prevenire il rischio di danneggiamento del pannello $OTHER_PANEL, rischio troppo elevato" - fi -fi - -# Run the domain/IP check up front to avoid late error out. -if [ "$INSTALL" == "EW" ]; then - - cyanMessage " " - cyanMessage "In quale URL/Dominio l'Easy-Wi dovrebbe essere posizionato?" - OPTIONS=("$HOST_NAME" "$LOCAL_IP" "Other" "Quit") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Other" ]; then - cyanMessage " " - cyanMessage "Perfavore, specifica l'IP o il dominio su cui l'Easy-Wi dovrebbe funzionare." - read IP_DOMAIN - else - IP_DOMAIN=$OPTION - fi - - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $IP_DOMAIN`" == "" -a "`grep -E '^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)*[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}$' <<< $IP_DOMAIN`" == "" ]; then - errorAndExit "Errore: $IP_DOMAIN non è né un dominio né un IPv4!" - fi -fi - -# Run the TS3 server version detect up front to avoid user executing steps first and fail at download last. -if [ "$INSTALL" == "VS" ]; then - - if [ "$MACHINE" == "x86_64" ]; then - ARCH="amd64" - elif [ "$MACHINE" == "i386" ]||[ "$MACHINE" == "i686" ]; then - ARCH="x86" - else - errorAndExit "$MACHINE non è supportata!" - fi - - okAndSleep "Cercando l'ultima build per hardware di tipo $MACHINE con architettura $ARCH." - - for VERSION in `curl -s "http://dl.4players.de/ts/releases/?C=M;O=D" | grep -Po '(?<=href=")[0-9]+(\.[0-9]+){2,3}(?=/")' | sort -Vr`; do - - DOWNLOAD_URL_VERSION="http://dl.4players.de/ts/releases/$VERSION/teamspeak3-server_linux_$ARCH-$VERSION.tar.bz2" - STATUS=`curl -I $DOWNLOAD_URL_VERSION 2>&1 | grep "HTTP/" | awk '{print $2}'` - - if [ "$STATUS" == "200" ]; then - DOWNLOAD_URL=$DOWNLOAD_URL_VERSION - break - fi - done - - if [ "$STATUS" == "200" -a "$DOWNLOAD_URL" != "" ]; then - okAndSleep "Rilevata l'ultima versione del server con versione $VERSION all'URL di download $DOWNLOAD_URL" - else - errorAndExit "Non posso rilevare l'ultima versione del server" - fi -fi - -# If we need to install and configure a webspace than we need to identify the groupID -if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - - WEBGROUPID=`getent group www-data | awk -F ':' '{print $3}'` - - if [ "$INSTALL" == "EW" ]; then - OPTION="Si" - else - cyanMessage " " - cyanMessage "Trovato il gruppo www-data con gruppo ID $WEBGROUPID. Usarlo come gruppo per i server web?" - - OPTIONS=("Si" "No" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$OPTION" == "No" ]; then - - cyanMessage "Perfavore scrivi il nome del gruppo da utilizzare per i server web" - read WEBGROUP - - WEBGROUPID=`getent group $WEBGROUP | awk -F ':' '{print $3}'` - - if [ "$WEBGROUPID" == "" ]; then - $GROUPADD $WEBGROUP - WEBGROUPID=`getent group $WEBGROUP | awk -F ':' '{print $3}'` - fi - fi - - if [ "$WEBGROUPID" == "" ]; then - errorAndExit "Errore fatale: ID del server web mancante" - fi -fi - -if [ "$INSTALL" != "MY" ]; then - - cyanMessage "Perfavore inserisci il nome dell'utente principale. Se non esiste, l'installer provvederà a crearlo." - read MASTERUSER - - if [ "$MASTERUSER" == "" ]; then - errorAndExit "Errore fatale: Nessun nome utente specificato" - fi - - if [ "`id $MASTERUSER 2> /dev/null`" == "" ]; then - - if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - $USERADD -m -b /home -s /bin/bash -g $WEBGROUPID $MASTERUSER - else - - if [ -d /home/$MASTERUSER ]; then - $GROUPADD $MASTERUSER - $USERADD -d /home/$MASTERUSER -s /bin/bash -g $MASTERUSER $MASTERUSER - else - $GROUPADD $MASTERUSER - $USERADD -m -b /home -s /bin/bash -g $MASTERUSER $MASTERUSER - fi - fi - - elif [ "$INSTALL" != "VS" -a "$INSTALL" != "MY" ]; then - - okAndSleep "Utente \"$MASTERUSER\" trovato, applicandogli \"$MASTERUSER\" come grppo principale" - - if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" ]; then - $USERMOD -G $WEBGROUPID $MASTERUSER - else - - if [ "`getent group $MASTERUSER`" == "" ]; then - $GROUPADD $MASTERUSER - fi - - $USERMOD -G $MASTERUSER $MASTERUSER - fi - else - okAndSleep "L'utente \"$MASTERUSER\" è già esistente." - fi - - cyanMessage " " - cyanMessage "Creare una chiave o impostare una password per il login?" - cyanMessage "Il modo più sicuro di effettuare il login è mediante una chiave protetta da password." - - if [ "$INSTALL" == "EW" ]; then - cyanMessage "Nessuno dei due è richiesto per l'installazione del pannello web dell' Easy-WI." - fi - - OPTIONS=("Crea una chiave" "Imposta una password" "Salta" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Crea una chiave" ]; then - - if [ -d /home/$MASTERUSER/.ssh ]; then - rm -rf /home/$MASTERUSER/.ssh - mkdir -p /home/$MASTERUSER/.ssh - chown $MASTERUSER:$MASTERUSER /home/$MASTERUSER/.ssh - fi - - cyanMessage " " - cyanMessage "È raccomandato ma non richesto impostare una password" - su -c "ssh-keygen -t rsa" $MASTERUSER - - cd /home/$MASTERUSER/.ssh - - KEYNAME=`find -maxdepth 1 -name "*.pub" | head -n 1` - - if [ "$KEYNAME" != "" ]; then - su -c "cat $KEYNAME >> authorized_keys" $MASTERUSER - else - redMessage "Errore: non posso trovare una chiave. Potresti dover crearne una manualemnte più avanti." - fi - - elif [ "$OPTION" == "Imposta una password" ]; then - passwd $MASTERUSER - fi -fi - -# only in case we want to manage webspace we need the additional skel dir -if [ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ]; then - makeDir /home/$MASTERUSER/sites-enabled/ - makeDir /home/$MASTERUSER/skel/htdocs - makeDir /home/$MASTERUSER/skel/logs - makeDir /home/$MASTERUSER/skel/session - makeDir /home/$MASTERUSER/skel/tmp -fi - -if [ "$INSTALL" == "EW" -o "$INSTALL" == "WR" -o "$INSTALL" == "MY" ]; then - - if [ "$OS" == "debian" -a "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Utilizzare la repo dotdeb.org per le aggiornare le versioni di PHP?" - - OPTIONS=("Si" "No" "Esci") - select DOTDEB in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$DOTDEB" == "Si" ]; then - if [ "`grep 'packages.dotdeb.org' /etc/apt/sources.list`" == "" ]; then - - okAndSleep "Aggiungendo le voci /etc/apt/sources.list" - - if [ "$OSBRANCH" == "squeeze" -o "$OSBRANCH" == "wheezy" ]; then - checkInstall python-software-properties - elif [ "$OSBRANCH" == "jessie" ]; then - checkInstall software-properties-common - fi - - add-apt-repository "deb http://packages.dotdeb.org $OSBRANCH all" - add-apt-repository "deb-src http://packages.dotdeb.org $OSBRANCH all" - curl --remote-name http://www.dotdeb.org/dotdeb.gpg - apt-key add dotdeb.gpg - removeIfExists dotdeb.gpg - apt-get update - fi - fi - fi - - if [ "$INSTALL" != "MY" ]; then - cyanMessage " " - cyanMessage "Perfavore selezione il server web che vorresti utilizzare" - fi - - if [ "$INSTALL" == "EW" ]; then - - cyanMessage "Apache è raccomandato in caso si vogliano utilizzare ulteriori siti soltre a questo host." - cyanMessage "Nginx è raccomandato se il server dovrebbe solo eseguire il pannello web Easy-WI." - - OPTIONS=("Nginx" "Apache" "Esci") - select WEBSERVER in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - elif [ "$INSTALL" != "MY" ]; then - - cyanMessage "Nginx è raccomandato per per il FastDL e un pò più efficente per i vhosts" - cyanMessage "Apache è raccomandato in caso in caso si voglia eseguire più siti in PHP supportando Vhosts ovvero hosting web in massa" - - OPTIONS=("Nginx" "Apache" "Lighttpd" "Nessuno" "Esci") - select WEBSERVER in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4 ) break;; - 5 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$WEBSERVER" == "Nginx" -a "$INSTALL" != "MY" ]; then - checkInstall nginx-full - elif [ "$WEBSERVER" == "Lighttpd" -a "$INSTALL" != "MY" ]; then - checkInstall lighttpd - elif [ "$WEBSERVER" == "Apache" -a "$INSTALL" != "MY" ]; then - checkInstall apache2 - fi - - if [ "$INSTALL" == "EW" ]; then - - okAndSleep "Perfavore, prendi nota del fatto che l'Easy-Wi richiede MySQL o MariaDB installato, ed installerà MySQL se nessun servizio risulterà installato" - - if [ "`ps ax | grep mysql | grep -v grep`" == "" ]; then - SQL="MySQL" - else - SQL="" - fi - - else - - cyanMessage " " - cyanMessage "Perfavore selezione quale database si desidera installare." - cyanMessage "Seleziona \"Nessuno\" nel caso il server debba essere utilizzato solamente come spazio web Fastdownload." - - OPTIONS=("MySQL" "MariaDB" "Nessuno" "Esci") - select SQL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$SQL" == "MySQL" -o "$SQL" == "MariaDB" ]; then - if [ "`ps fax | grep 'mysqld' | grep -v 'grep'`" ]; then - - cyanMessage " " - cyanMessage "Perfavore fornisci ;a password di root per il database." - read MYSQL_ROOT_PASSWORD - - mysql -uroot -p$MYSQL_ROOT_PASSWORD -e exit 2> /dev/null - ERROR_CODE=$? - - until [ $ERROR_CODE == 0 ]; do - - cyanMessage "Password non corretta, perfavore fornisci la password di root per il database." - read MYSQL_ROOT_PASSWORD - - mysql -uroot -p$MYSQL_ROOT_PASSWORD -e exit 2> /dev/null - ERROR_CODE=$? - done - - else - until [ "$MYSQL_ROOT_PASSWORD" != "" ]; do - cyanMessage "Perfavore fornisci la passwrod di root per il database." - read MYSQL_ROOT_PASSWORD - done - fi - - export DEBIAN_FRONTEND="noninteractive" - echo "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections - echo "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | debconf-set-selections - fi - - if [ "$SQL" == "MySQL" ]; then - - apt-get install mysql-server mysql-client mysql-common -y - - elif [ "$SQL" == "MariaDB" ]; then - - RUNUPDATE=0 - - if ([ "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "8.0" -o "$OS" == "ubuntu" ] && [ "`grep '/mariadb/' /etc/apt/sources.list`" == "" ]); then - - checkInstall python-software-properties - apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db - - if [ "$SQL" == "MariaDB" -a "`apt-cache search mariadb-server-10.0`" == "" ]; then - if [ "$OS" == "debian" ]; then - add-apt-repository "deb http://mirror.netcologne.de/mariadb/repo/10.0/debian $OSBRANCH main" - RUNUPDATE=1 - elif [ "$OS" == "ubuntu" ]; then - add-apt-repository "deb http://mirror.netcologne.de/mariadb/repo/10.0/ubuntu $OSBRANCH main" - RUNUPDATE=1 - fi - fi - fi - - if [ "$OS" == "debian" -a "$DOTDEB" == "Si" ]; then - echo "Package: *" > /etc/apt/preferences.d/mariadb.pref - echo "Pin: origin mirror.netcologne.de" >> /etc/apt/preferences.d/mariadb.pref - echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/mariadb.pref - RUNUPDATE=1 - fi - - if [ "$RUNUPDATE" == "1" ]; then - apt-get update - fi - - if ([ "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "8.0" -o "$OS" == "ubuntu" ] && [ "`grep '/mariadb/' /etc/apt/sources.list`" == "" ]); then - apt-get install mariadb-server mariadb-client mysql-common -y - else - apt-get install mariadb-server mariadb-client mariadb-common -y - fi - fi - - if [ "$SQL" == "MySQL" -o "$SQL" == "MariaDB" ]; then - - if [ "$INSTALL" == "WR" -o "$INSTALL" == "MY" ]; then - - cyanMessage " " - cyanMessage "Il pannello Easy-Wi è installato su un server diverso da questo?." - - OPTIONS=("Si" "No" "Esci") - select EXTERNAL_INSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - cyanMessage " " - okAndSleep "Securing MySQL by running \"mysql_secure_installation\" commands." - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.user WHERE User=''" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "FLUSH PRIVILEGES" 2> /dev/null - fi - - if [ "$EXTERNAL_INSTALL" == "Si" ]; then - - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "GRANT USAGE ON *.* TO 'root'@'' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0" 2> /dev/null - mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "UPDATE mysql.user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y' WHERE User='root' AND Host=''" 2> /dev/null - - if [ "$LOCAL_IP" == "" ]; then - - cyanMessage " " - cyanMessage "Non posso riconoscere l'IP locale. Perfavore specifica quale usare." - read LOCAL_IP - fi - - if [ "$LOCAL_IP" != "" -a -f /etc/mysql/my.cnf ]; then - if [ "`grep 'bind-address' /etc/mysql/my.cnf`" ]; then - sed -i "s/bind-address.*/bind-address = 0.0.0.0/g" /etc/mysql/my.cnf - else - echo "bind-address = 0.0.0.0" >> /etc/mysql/my.cnf - fi - fi - fi - - MYSQL_VERSION=`mysql -V | awk {'print $5'} | tr -d ,` - - if [ "`grep -E 'key_buffer[[:space:]]*=' /etc/mysql/my.cnf`" != "" -a "printf "${MYSQL_VERSION}\n5.5" | sort -V | tail -n 1" != 5.5 ]; then - sed -i "s/key_buffer[[:space:]]*=/key_buffer_size = /g" /etc/mysql/my.cnf - fi - - /etc/init.d/mysql restart - - if [ "$INSTALL" == "EW" -a "`ps ax | grep mysql | grep -v grep`" == "" ]; then - cyanMessage " " - errorAndExit "Errore: nessun server SQL è attualemte in esecuzione, tuttavia questo è richiesto dal pannello web." - fi - - if [ "$INSTALL" == "EW" ]; then - - okAndSleep "Perfavore, prendere nota del fatto che l'Easy-Wi installerà i pacchetti PHP richiesti." - PHPINSTALL="Si" - - elif [ "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Installare/Aggiornare PHP?" - cyanMessage "Selezionare \"Nessuno\" nel caso il server debba ospitare solo webserver Fastdownload." - - OPTIONS=("Si" "No" "Nessuno" "Esci") - select PHPINSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3 ) break;; - 4 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - fi - - if [ "$PHPINSTALL" == "Si" ]; then - - USE_PHP_VERSION='5' - - if [ "$OS" == "ubuntu" -a "`printf "${OSVERSION}\n16.03" | sort -V | tail -n 1`" != "16.03" ]; then - USE_PHP_VERSION='7.0' - fi - - if [ "$OS" == "debian" -a "$DOTDEB" == "Si" ]; then - - cyanMessage " " - - if [ "$OSBRANCH" == "wheezy" ]; then - - cyanMessage "Quale versione di PHP dovrebbe essere utilizzata?" - - OPTIONS=("5.4" "5.5", "5.6", "5.6 Zend thread safety" "Esci") - select DOTDEBPHPUPGRADE in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2|3|4 ) break;; - 5 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$DOTDEBPHPUPGRADE" == "5.5" -a "`grep 'wheezy-php55' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php55 all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php55 all" - elif [ "$DOTDEBPHPUPGRADE" == "5.6" -a "`grep 'wheezy-php56' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php56 all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php56 all" - elif [ "$DOTDEBPHPUPGRADE" == "5.6 Zend thread safety" -a "`grep 'wheezy-php56-zts' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org wheezy-php56-zts all" - add-apt-repository "deb-src http://packages.dotdeb.org wheezy-php56-zts all" - fi - - elif [ "$OSBRANCH" == "squeeze" -a "`grep 'squeeze-php54' /etc/apt/sources.list`" == "" ]; then - add-apt-repository "deb http://packages.dotdeb.org squeeze-php54 all" - add-apt-repository "deb-src http://packages.dotdeb.org squeeze-php54 all" - fi - - if [ "$DOTDEBPHPUPGRADE" == "Si" ]; then - apt-get update - apt-get upgrade -y && apt-get dist-upgrade -y - fi - fi - - checkInstall php${USE_PHP_VERSION}-common - checkInstall php${USE_PHP_VERSION}-curl - checkInstall php${USE_PHP_VERSION}-gd - checkInstall php${USE_PHP_VERSION}-mcrypt - checkInstall php${USE_PHP_VERSION}-mysql - checkInstall php${USE_PHP_VERSION}-cli - - if [ "$WEBSERVER" == "Nginx" -o "$WEBSERVER" == "Lighttpd" ]; then - - checkInstall php${USE_PHP_VERSION}-fpm - - if [ "$WEBSERVER" == "Lighttpd" ]; then - lighttpd-enable-mod fastcgi - lighttpd-enable-mod fastcgi-php - fi - - makeDir /home/$MASTERUSER/fpm-pool.d/ - sed -i "s/include=\/etc\/php5\/fpm\/pool.d\/\*.conf/include=\/home\/$MASTERUSER\/fpm-pool.d\/\*.conf/g" /etc/php5/fpm/php-fpm.conf - sed -i "s/include=\/etc\/php/7.0\/fpm\/pool.d\/\*.conf/include=\/home\/$MASTERUSER\/fpm-pool.d\/\*.conf/g" /etc/php/7.0/fpm/php-fpm.conf - - elif [ "$WEBSERVER" == "Apache" ]; then - checkInstall apache2-mpm-itk - checkInstall libapache2-mpm-itk - checkInstall libapache2-mod-php${USE_PHP_VERSION} - checkInstall php${USE_PHP_VERSION} - a2enmod php${USE_PHP_VERSION} - fi - - #In case of php 7 the socket is different - PHP_VERSION=`php -v | grep -E '^PHP' | awk '{print $2}' | awk -F '.' '{print $1}'` - PHP_SOCKET="/var/run/php${PHP_VERSION}-fpm-${FILE_NAME}.sock" - fi -fi - -if ([ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ] && [ "`grep '/bin/false' /etc/shells`" == "" ]); then - echo "/bin/false" >> /etc/shells -fi - -if [ "$INSTALL" != "VS" -a "$INSTALL" != "EW" -a "$INSTALL" != "MY" ]; then - - cyanMessage " " - cyanMessage "Installare/Aggiornare ProFTPD?" - - OPTIONS=("Si" "No" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Si" ]; then - - echo "proftpd-basic shared/proftpd/inetd_or_standalone select standalone" | debconf-set-selections - apt-get install proftpd -y - - if [ -f /etc/proftpd/modules.conf ]; then - - backUpFile /etc/proftpd/modules.conf - - sed -i 's/.*LoadModule mod_tls_memcache.c.*/#LoadModule mod_tls_memcache.c/g' /etc/proftpd/modules.conf - fi - - backUpFile /etc/proftpd/proftpd.conf - - sed -i 's/.*UseIPv6.*/UseIPv6 off/g' /etc/proftpd/proftpd.conf - sed -i 's/#.*DefaultRoot.*~/DefaultRoot ~/g' /etc/proftpd/proftpd.conf - sed -i 's/# RequireValidShell.*/RequireValidShell on/g' /etc/proftpd/proftpd.conf - - if [ -f /etc/proftpd/proftpd.conf -a "$INSTALL" != "GS" ]; then - - sed -i 's/Umask.*/Umask 037 027/g' /etc/proftpd/proftpd.conf - - elif [ -f /etc/proftpd/proftpd.conf -a "$INSTALL" == "GS" ]; then - - sed -i 's/Umask.*/Umask 077 077/g' /etc/proftpd/proftpd.conf - - cyanMessage " " - cyanMessage "Install/Update ProFTPD Rules?" - - OPTIONS=("Si" "No" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Si" -a "`grep '' /etc/proftpd/proftpd.conf`" == "" -a ! -f "/etc/proftpd/conf.d/easy-wi.conf" ]; then - - makeDir /etc/proftpd/conf.d/ - chmod 755 /etc/proftpd/conf.d/ - - echo " - - HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on - - DenyAll - -" > /etc/proftpd/conf.d/easy-wi.conf - echo "" >> /etc/proftpd/conf.d/easy-wi.conf - echo " HideFiles (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - PathDenyFilter (^\..+|\.ssh|\.bash_history|\.bash_logout|\.bashrc|\.profile)$ - HideNoAccess on - Umask 137 027 - - AllowAll - - - - Umask 077 077 - - AllowAll - - - - Umask 177 077 - - AllowAll - - - - HideFiles (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - PathDenyFilter (^\..+|srcds_run|srcds_linux|hlds_run|hlds_amd|hlds_i686|\.rc|\.sh|\.zip|\.rar|\.7z|\.dll)$ - HideNoAccess on -" >> /etc/proftpd/conf.d/easy-wi.conf - - - GAMES=("ark" "arma3" "bukkit" "hexxit" "mc" "mtasa" "projectcars" "rust" "samp" "spigot" "teeworlds" "tekkit" "tekkit-classic") - - for GAME in ${GAMES[@]}; do - echo " - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - - GAME_MODS=("csgo" "cstrike" "czero" "orangebox" "dod" "garrysmod") - - for GAME_MOD in ${GAME_MODS[@]}; do - echo " - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - - FOLDERS=("addons" "cfg" "maps") - - for FOLDER in ${FOLDERS[@]}; do - echo " - Umask 077 077 - - AllowAll - - - - Umask 077 077 - - AllowAll - -" >> /etc/proftpd/conf.d/easy-wi.conf - done - fi - fi - - if [ -f /etc/init.d/proftpd ]; then - service proftpd restart - fi - fi -fi - -if [ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ]; then - - cyanMessage " " - cyanMessage "Installare Quota?" - - OPTIONS=("Si" "No" "Esci") - select QUOTAINSTALL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$QUOTAINSTALL" == "Si" ]; then - - checkInstall quota - - cyanMessage " " - cyanMessage " " - removeIfExists /root/tempfstab - removeIfExists /root/tempmountpoints - - cat /etc/fstab | while read LINE; do - if [[ `echo $LINE | grep '/' | egrep -v '#|boot|proc|swap|floppy|cdrom|usrquota|usrjquota|/sys|/shm|/pts'` ]]; then - CURRENTOPTIONS=`echo $LINE | awk '{print $4}'` - echo $LINE | sed "s/$CURRENTOPTIONS/$CURRENTOPTIONS,usrjquota=aquota.user,jqfmt=vfsv0/g" >> /root/tempfstab - echo $LINE | awk '{print $2}' >> /root/tempmountpoints - else - echo $LINE >> /root/tempfstab - fi - done - - cat /root/tempfstab - - cyanMessage " " - cyanMessage " " - cyanMessage "perfavore, controlla l'output sovrestante ed assicurati che sia corretto. Alla conferma, il file /etc/fstab sarà sostituito per poter attivare Quotas!" - - OPTIONS=("Si" "No" "Esci") - select QUOTAFSTAB in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$QUOTAFSTAB" == "Si" ]; then - backUpFile /etc/fstab - mv /root/tempfstab /etc/fstab - fi - - removeIfExists /root/tempfstab - removeIfExists /aquota.user - touch /aquota.user - chmod 600 /aquota.user - - if [ -f /root/tempmountpoints ]; then - - cat /root/tempmountpoints | while read LINE; do - - quotaoff -ugv $LINE - - removeIfExists $LINE/aquota.user - - okAndSleep "Rimontando $LINE" - mount -o remount $LINE - - quotacheck -vumc $LINE - quotaon -uv $LINE - done - - removeIfExists /root/tempmountpoints - fi - fi -fi - -if [ "$INSTALL" == "WR" -o "$INSTALL" == "EW" ]; then - - if [ "$WEBSERVER" == "Nginx" ]; then - - backUpFile /etc/nginx/nginx.conf - - if [ "`grep '/home/$MASTERUSER/sites-enabled/' /etc/nginx/nginx.conf`" == "" ]; then - sed -i "\/etc\/nginx\/sites-enabled\/\*;/a \ \ \ \ \ \ \ \ include \/home\/$MASTERUSER\/sites-enabled\/\*;" /etc/nginx/nginx.conf - fi - - elif [ "$WEBSERVER" == "Lighttpd" ]; then - - backUpFile /etc/lighttpd/lighttpd.conf - echo "include_shell \"find /home/$MASTERUSER/sites-enabled/ -maxdepth 1 -type f -exec cat {} \;\"" >> /etc/lighttpd/lighttpd.conf - - elif [ "$WEBSERVER" == "Apache" ]; then - - backUpFile /etc/apache2/apache2.conf - - if [ "`grep 'ServerName localhost' /etc/apache2/apache2.conf`" == "" ]; then - echo '# Added to prevent error message Could not reliably determine the servers fully qualified domain name' >> /etc/apache2/apache2.conf - echo 'ServerName localhost' >> /etc/apache2/apache2.conf - fi - - APACHE_VERSION=`apache2 -v | grep 'Server version'` - - if [ "`grep '/home/$MASTERUSER/sites-enabled/' /etc/apache2/apache2.conf`" == "" ]; then - if [[ $APACHE_VERSION =~ .*Apache/2.2.* ]]; then - sed -i "/Include sites-enabled\//a Include \/home\/$MASTERUSER\/sites-enabled\/" /etc/apache2/apache2.conf - sed -i "/Include \/etc\/apache2\/sites-enabled\//a \/home\/$MASTERUSER\/sites-enabled\/" /etc/apache2/apache2.conf - else - sed -i "/IncludeOptional sites-enabled\//a IncludeOptional \/home\/$MASTERUSER\/sites-enabled\/*.conf" /etc/apache2/apache2.conf - sed -i "/IncludeOptional \/etc\/apache2\/sites-enabled\//a IncludeOptional \/home\/$MASTERUSER\/sites-enabled\/*.conf" /etc/apache2/apache2.conf - fi - fi - - okAndSleep "Attivando il modulo mod_rewrite di Apache." - a2enmod rewrite - a2enmod version 2> /dev/null - fi - - #TODO: Logrotate -fi - -# No direct root access for masteruser. Only limited access through sudo -if [ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ]; then - - checkInstall sudo - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERADD`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERADD" >> /etc/sudoers - fi - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERMOD`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERMOD" >> /etc/sudoers - fi - - if [ -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep $USERDEL`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $USERDEL" >> /etc/sudoers - fi - - if [ "$QUOTAINSTALL" == "Si" -a -f /etc/sudoers ]; then - if [ "`grep $MASTERUSER /etc/sudoers | grep setquota`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: `which setquota`" >> /etc/sudoers - fi - - if [ "`grep $MASTERUSER /etc/sudoers | grep repquota`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: `which repquota`" >> /etc/sudoers - fi - fi - - if [ "$INSTALL" == "GS" -a -f /etc/sudoers -a "`grep $MASTERUSER /etc/sudoers | grep temp`" == "" ]; then - echo "$MASTERUSER ALL = (ALL, !root:easywi) NOPASSWD: /home/$MASTERUSER/temp/*.sh" >> /etc/sudoers - fi - - if [ "$WEBSERVER" == "Nginx" ]; then - HTTPDBIN=`which nginx` - HTTPDSCRIPT="/etc/init.d/nginx" - elif [ "$WEBSERVER" == "Lighttpd" ]; then - HTTPDBIN=`which lighttpd` - HTTPDSCRIPT="/etc/init.d/lighttpd" - elif [ "$WEBSERVER" == "Apache" ]; then - HTTPDBIN=`which apache2` - HTTPDSCRIPT="/etc/init.d/apache2" - fi - - if [ "$HTTPDBIN" != "" -a -f /etc/sudoers ]; then - if [ "`grep $MASTERUSER /etc/sudoers | grep $HTTPDBIN`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $HTTPDBIN" >> /etc/sudoers - fi - - if [ "`grep $MASTERUSER /etc/sudoers | grep $HTTPDSCRIPT`" == "" ]; then - echo "$MASTERUSER ALL = NOPASSWD: $HTTPDSCRIPT" >> /etc/sudoers - fi - fi -fi - -if [ "$INSTALL" == "WR" ]; then - - chown -R $MASTERUSER:$WEBGROUPID /home/$MASTERUSER/ - - greenMessage "I seguenti dati devono essere inseriti nel pannello Easy-Wi:" - - greenMessage "Il percorso alla cartella \"sites-enabled\" è:" - greenMessage "/home/$MASTERUSER/sites-enabled/" - - greenMessage "Il comando per aggiungere un utente è:" - greenMessage "sudo $USERADD %cmd%" - - greenMessage "Il comando usermod è:" - greenMessage "sudo $USERMOD %cmd%" - - greenMessage "Il comando userdel è:" - greenMessage "sudo $USERDEL %cmd%" - - greenMessage "Il comando per riavviare HTTPD è:" - greenMessage "sudo $HTTPDSCRIPT reload" -fi - -if ([ "$INSTALL" == "GS" -o "$INSTALL" == "WR" ] && [ "$QUOTAINSTALL" == "Si" ]); then - greenMessage "Il comapndo per impostare i quota è:" - greenMessage "sudo `which setquota` %cmd%" - greenMessage "Il comando per soostituire i quota è:" - greenMessage "sudo `which repquota` %cmd%" -fi - -if [ "$INSTALL" == "GS" ]; then - - cyanMessage " " - cyanMessage "Java JRE è richiesto per eseguire Minecraft e le sue mod. Dovrebbe essere installato?" - OPTIONS=("Si" "No" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - if [ "$OPTION" == "Si" ]; then - checkInstall default-jre - fi - - okAndSleep "Crando le cartelle ed i files" - CREATEDIRS=("conf" "fdl_data/hl2" "logs" "masteraddons" "mastermaps" "masterserver" "temp") - for CREATEDIR in ${CREATEDIRS[@]}; do - greenMessage "Aggiungendo la directory: /home/$MASTERUSER/$CREATEDIR" - makeDir /home/$MASTERUSER/$CREATEDIR - done - - LOGFILES=("addons" "hl2" "server" "fdl" "update" "fdl-hl2") - for LOGFILE in ${LOGFILES[@]}; do - touch "/home/$MASTERUSER/logs/$LOGFILE.log" - done - chmod 660 /home/$MASTERUSER/logs/*.log - - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER/ - chmod -R 750 /home/$MASTERUSER/ - chmod -R 770 /home/$MASTERUSER/logs/ /home/$MASTERUSER/temp/ /home/$MASTERUSER/fdl_data/ - - if [ "$OS" == "debian" -a "`uname -m`" == "x86_64" -a "`cat /etc/debian_version | grep '6.'`" == "" ]; then - dpkg --add-architecture i386 - fi - - if [ "$OS" == "debian" -o "$OS" == "ubuntu" ]; then - - okAndSleep "installando i pacchetti richiesti: wput screen bzip2 sudo rsync zip unzip" - apt-get install wput screen bzip2 sudo rsync zip unzip -y - - if [ "`uname -m`" == "x86_64" ]; then - - okAndSleep "Installando il supporto a 32bit per i sistemi a 64bit." - - if ([ "$OS" == "ubuntu" ] || [ "$OS" == "debian" -a "`printf "${OSVERSION}\n8.0" | sort -V | tail -n 1`" == "$OSVERSION" ]); then - apt-get install zlib1g lib32z1 lib32gcc1 lib32readline5 lib32ncursesw5 -y - apt-get install lib32stdc++6 -y - apt-get install lib64stdc++6 -y - apt-get install libstdc++6 -y - apt-get install libgcc1:i386 -y - apt-get install libreadline5:i386 -y - apt-get install libncursesw5:i386 -y - apt-get install zlib1g:i386 -y - else - apt-get install ia32-libs lib32readline5 lib32ncursesw5 lib32stdc++6 -y - fi - else - apt-get install libreadline5 libncursesw5 -y - fi - fi - - okAndSleep "Scaricando SteamCmd" - - cd /home/$MASTERUSER/masterserver - makeDir /home/$MASTERUSER/masterserver/steamCMD/ - cd /home/$MASTERUSER/masterserver/steamCMD/ - curl --remote-name http://media.steampowered.com/client/steamcmd_linux.tar.gz - - if [ -f steamcmd_linux.tar.gz ]; then - tar xfvz steamcmd_linux.tar.gz - removeIfExists steamcmd_linux.tar.gz - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER/masterserver/steamCMD - su -c "./steamcmd.sh +login anonymous +quit" $MASTERUSER - if [ -f /home/$MASTERUSER/masterserver/steamCMD/linux32/steamclient.so ]; then - su -c "mkdir -p ~/.steam/sdk32/" $MASTERUSER - su -c "chmod 750 -R ~/.steam/" $MASTERUSER - su -c "ln -s ~/masterserver/steamCMD/linux32/steamclient.so ~/.steam/sdk32/steamclient.so" $MASTERUSER - fi - fi - - chown -R $INSTALLMASTER:$INSTALLMASTER /home/$INSTALLMASTER - - if [ -f /etc/crontab -a "`grep 'Minecraft can easily produce 1GB' /etc/crontab`" == "" ]; then - - if ionice -c3 true 2>/dev/null; then - IONICE="ionice -n 7 " - fi - - echo "#Minecraft can easily produce 1GB+ logs within one hour" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 ionice -n 7 find /home/*/server/*/*/ -maxdepth 2 -type f -name \"screenlog.0\" -size +100M -delete" >> /etc/crontab - echo "# Even sudo /usr/sbin/deluser --remove-all-files is used some data remain from time to time" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /home/ -maxdepth 2 -type d -nouser -delete" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /home/*/fdl_data/ /home/*/temp/ /tmp/ /var/run/screen/ -nouser -print0 | xargs -0 rm -rf" >> /etc/crontab - echo "*/5 * * * * root nice -n +19 $IONICE find /var/run/screen/ -maxdepth 1 -type d -nouser -print0 | xargs -0 rm -rf" >> /etc/crontab - - service cron restart - fi -fi - -if [ "$INSTALL" == "EW" ]; then - - makeDir /home/$MASTERUSER/fpm-pool.d/ - - if [ -f /home/easywi_web/htdocs/serverallocation.php ]; then - - cyanMessage " " - cyanMessage "È già presente una installazione eistente. Dovrebbe essere rimossa?" - OPTIONS=("Si" "Esci") - select OPTION in "${OPTIONS[@]}"; do - case "$REPLY" in - 1 ) break;; - 2 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - rm -rf /home/easywi_web/htdocs/* - fi - - if [ "`id easywi_web 2> /dev/null`" == "" -a ! -d /home/easywi_web ]; then - $USERADD -md /home/easywi_web -g www-data -s /bin/bash -k /home/$MASTERUSER/skel/ easywi_web - elif [ "`id easywi_web 2> /dev/null`" == "" -a -d /home/easywi_web ]; then - $USERADD -d /home/easywi_web -g www-data -s /bin/bash easywi_web - fi - - makeDir /home/easywi_web/htdocs/ - makeDir /home/easywi_web/logs/ - makeDir /home/easywi_web/tmp/ - makeDir /home/easywi_web/session/ - chown -R easywi_web:$WEBGROUPID /home/easywi_web/htdocs/ /home/easywi_web/logs/ /home/easywi_web/tmp/ /home/easywi_web/session/ - - if [ "`id easywi_web 2> /dev/null`" == "" ]; then - errorAndExit "L'utente web easywi_web non esiste! Uscendo ora!" - fi - - if [ ! -d /home/easywi_web/htdocs ]; then - errorAndExit "Nessuna cartella creata in home/htdocs! Uscendo ora!" - fi - - checkInstall unzip - - cd /home/easywi_web/htdocs/ - - okAndSleep "Scaricando l'ultima versione dell'Easy-Wi stabile." - curl https://easy-wi.com/uk/downloads/get/3/ -o web.zip - - if [ ! -f web.zip ]; then - errorAndExit "Non posso scaricare l'Easy-Wi. Abortendo!" - fi - - okAndSleep "Decomprimendo l'archivio contenente l'Easy-WI." - unzip -u web.zip >/dev/null 2>&1 - removeIfExists web.zip - - find /home/easywi_web/ -type f -print0 | xargs -0 chmod 640 - find /home/easywi_web/ -mindepth 1 -type d -print0 | xargs -0 chmod 750 - - chown -R easywi_web:www-data /home/easywi_web - - DB_PASSWORD=`< /dev/urandom tr -dc A-Za-z0-9 | head -c18` - - okAndSleep "Creando il database easy_wi e connettendomici con l'utente easy_wi" - mysql -uroot -p$MYSQL_ROOT_PASSWORD -Bse "CREATE DATABASE IF NOT EXISTS easy_wi; GRANT ALL ON easy_wi.* TO 'easy_wi'@'localhost' IDENTIFIED BY '$DB_PASSWORD'; FLUSH PRIVILEGES;" - - cyanMessage " " - cyanMessage "Proteggere i Vhost con SSL? (raccomandato!)" - OPTIONS=("Si" "No" "Esci") - select SSL in "${OPTIONS[@]}"; do - case "$REPLY" in - 1|2 ) break;; - 3 ) errorAndQuit;; - *) errorAndContinue;; - esac - done - - FILE_NAME=${IP_DOMAIN//./_} - - if [ "$SSL" == "Si" ]; then - - checkInstall openssl - - if [ "$WEBSERVER" == "Nginx" ]; then - SSL_DIR=/etc/nginx/ssl - elif [ "$WEBSERVER" == "Apache" ]; then - SSL_DIR=/etc/apache2/ssl - fi - - makeDir $SSL_DIR - - cyanMessage " " - okAndSleep "Creando un certificato SSL autofirmato." - openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $SSL_DIR/$FILE_NAME.key -out $SSL_DIR/$FILE_NAME.crt -subj "/C=/ST=/L=/O=/OU=/CN=$IP_DOMAIN" - fi - - if [ "$WEBSERVER" == "Nginx" -o "$WEBSERVER" == "Lighttpd" ]; then - - FILE_NAME_POOL=/home/$MASTERUSER/fpm-pool.d/$FILE_NAME.conf - - echo "[$IP_DOMAIN]" > $FILE_NAME_POOL - echo "user = easywi_web" >> $FILE_NAME_POOL - echo "group = www-data" >> $FILE_NAME_POOL - echo "listen = ${PHP_SOCKET}" >> $FILE_NAME_POOL - echo "listen.owner = easywi_web" >> $FILE_NAME_POOL - echo "listen.group = www-data" >> $FILE_NAME_POOL - echo "pm = dynamic" >> $FILE_NAME_POOL - echo "pm.max_children = 1" >> $FILE_NAME_POOL - echo "pm.start_servers = 1" >> $FILE_NAME_POOL - echo "pm.min_spare_servers = 1" >> $FILE_NAME_POOL - echo "pm.max_spare_servers = 1" >> $FILE_NAME_POOL - echo "pm.max_requests = 500" >> $FILE_NAME_POOL - echo "chdir = /" >> $FILE_NAME_POOL - echo "access.log = /home/easywi_web/logs/fpm-access.log" >> $FILE_NAME_POOL - echo "php_flag[display_errors] = off" >> $FILE_NAME_POOL - echo "php_admin_flag[log_errors] = on" >> $FILE_NAME_POOL - echo "php_admin_value[error_log] = /home/easywi_web/logs/fpm-error.log" >> $FILE_NAME_POOL - echo "php_admin_value[memory_limit] = 32M" >> $FILE_NAME_POOL - echo "php_admin_value[open_basedir] = /home/easywi_web/htdocs/:/home/easywi_web/tmp/" >> $FILE_NAME_POOL - echo "php_admin_value[upload_tmp_dir] = /home/easywi_web/tmp" >> $FILE_NAME_POOL - echo "php_admin_value[session.save_path] = /home/easywi_web/session" >> $FILE_NAME_POOL - - chown $MASTERUSER:www-data $FILE_NAME_POOL - fi - - FILE_NAME_VHOST=/home/$MASTERUSER/sites-enabled/$FILE_NAME - - if [ "$WEBSERVER" == "Nginx" ]; then - echo 'server {' > $FILE_NAME_VHOST - echo ' listen 80;' >> $FILE_NAME_VHOST - - if [ "$SSL" == "Si" ]; then - - echo " server_name $IP_DOMAIN;" >> $FILE_NAME_VHOST - echo " return 301 https://$IP_DOMAIN"'$request_uri;' >> $FILE_NAME_VHOST - echo '}' >> $FILE_NAME_VHOST - - backUpFile /etc/nginx/nginx.conf - - if [ "`grep 'ssl_ecdh_curve secp384r1;' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_ecdh_curve secp384r1;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_session_cache' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_session_cache shared:SSL:10m;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_session_timeout' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_session_timeout 10m;' /etc/nginx/nginx.conf - fi - if [ "`grep 'ssl_ciphers' /etc/nginx/nginx.conf`" == "" ]; then - sed -i '/ssl_prefer_server_ciphers on;/a \\tssl_ciphers EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:!MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL;' /etc/nginx/nginx.conf - fi - - echo 'server {' >> $FILE_NAME_VHOST - echo ' listen 443 ssl;' >> $FILE_NAME_VHOST - echo " ssl_certificate /etc/nginx/ssl/$FILE_NAME.crt;" >> $FILE_NAME_VHOST - echo " ssl_certificate_key /etc/nginx/ssl/$FILE_NAME.key;" >> $FILE_NAME_VHOST - fi - - echo ' root /home/easywi_web/htdocs/;' >> $FILE_NAME_VHOST - echo ' index index.html index.htm index.php;' >> $FILE_NAME_VHOST - echo " server_name $IP_DOMAIN;" >> $FILE_NAME_VHOST - echo ' location ~ /(keys|stuff|template|languages|downloads|tmp) { deny all; }' >> $FILE_NAME_VHOST - echo ' location / {' >> $FILE_NAME_VHOST - echo ' try_files $uri $uri/ =404;' >> $FILE_NAME_VHOST - echo ' }' >> $FILE_NAME_VHOST - echo ' location ~ \.php$ {' >> $FILE_NAME_VHOST - echo ' fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> $FILE_NAME_VHOST - echo ' try_files $fastcgi_script_name =404;' >> $FILE_NAME_VHOST - echo ' set $path_info $fastcgi_path_info;' >> $FILE_NAME_VHOST - echo ' fastcgi_param PATH_INFO $path_info;' >> $FILE_NAME_VHOST - echo ' fastcgi_index index.php;' >> $FILE_NAME_VHOST - - if [ -f /etc/nginx/fastcgi.conf ]; then - echo ' include /etc/nginx/fastcgi.conf;' >> $FILE_NAME_VHOST - elif [ -f /etc/nginx/fastcgi_params ]; then - echo ' include /etc/nginx/fastcgi_params;' >> $FILE_NAME_VHOST - fi - - echo " fastcgi_pass unix:${PHP_SOCKET};" >> $FILE_NAME_VHOST - echo ' }' >> $FILE_NAME_VHOST - echo '}' >> $FILE_NAME_VHOST - - chown -R $MASTERUSER:$WEBGROUPID /home/$MASTERUSER/ - - okAndSleep "Riavviando PHP-FPM e Nginx." - service php${USE_PHP_VERSION}-fpm restart - service nginx restart - - elif [ "$WEBSERVER" == "Apache" ]; then - - FILE_NAME_VHOST="$FILE_NAME_VHOST.conf" - - echo '' > $FILE_NAME_VHOST - echo " ServerName $IP_DOMAIN" >> $FILE_NAME_VHOST - echo " ServerAdmin info@$IP_DOMAIN" >> $FILE_NAME_VHOST - - if [ "$SSL" == "Si" ]; then - - echo " Redirect permanent / https://$IP_DOMAIN/" >> $FILE_NAME_VHOST - echo '' >> $FILE_NAME_VHOST - - okAndSleep "Activating TLS/SSL related Apache modules." - a2enmod ssl - service apache2 restart - - echo '' >> $FILE_NAME_VHOST - echo " ServerName $IP_DOMAIN" >> $FILE_NAME_VHOST - echo ' SSLEngine on' >> $FILE_NAME_VHOST - echo " SSLCertificateFile /etc/apache2/ssl/$FILE_NAME.crt" >> $FILE_NAME_VHOST - echo " SSLCertificateKeyFile /etc/apache2/ssl/$FILE_NAME.key" >> $FILE_NAME_VHOST - - fi - - - echo ' DocumentRoot "/home/easywi_web/htdocs/"' >> $FILE_NAME_VHOST - echo ' ErrorLog "/home/easywi_web/logs/error.log"' >> $FILE_NAME_VHOST - echo ' CustomLog "/home/easywi_web/logs/access.log" common' >> $FILE_NAME_VHOST - echo ' DirectoryIndex index.php index.html' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' AssignUserId easywi_web www-data' >> $FILE_NAME_VHOST - echo ' MaxClientsVHost 50' >> $FILE_NAME_VHOST - echo ' NiceValue 10' >> $FILE_NAME_VHOST - echo ' php_admin_flag allow_url_include off' >> $FILE_NAME_VHOST - echo ' php_admin_flag display_errors off' >> $FILE_NAME_VHOST - echo ' php_admin_flag log_errors on' >> $FILE_NAME_VHOST - echo ' php_admin_flag mod_rewrite on' >> $FILE_NAME_VHOST - echo ' php_admin_value open_basedir "/home/easywi_web/htdocs/:/home/easywi_web/tmp"' >> $FILE_NAME_VHOST - echo ' php_admin_value session.save_path "/home/easywi_web/session"' >> $FILE_NAME_VHOST - echo ' php_admin_value upload_tmp_dir "/home/easywi_web/tmp"' >> $FILE_NAME_VHOST - echo ' php_admin_value upload_max_size 32M' >> $FILE_NAME_VHOST - echo ' php_admin_value memory_limit 32M' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Options -Indexes +FollowSymLinks +Includes' >> $FILE_NAME_VHOST - echo ' AllowOverride None' >> $FILE_NAME_VHOST - echo ' = 2.4>' >> $FILE_NAME_VHOST - echo ' Require all granted' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Order allow,deny' >> $FILE_NAME_VHOST - echo ' Allow from all' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' = 2.4>' >> $FILE_NAME_VHOST - echo ' Require all denied' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' Order deny,allow' >> $FILE_NAME_VHOST - echo ' Deny from all' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo ' ' >> $FILE_NAME_VHOST - echo '' >> $FILE_NAME_VHOST - - okAndSleep "Riavviando Apache2." - service apache2 restart - fi - - chown $MASTERUSER:www-data $FILE_NAME_VHOST - - if [ "`grep reboot.php /etc/crontab`" == "" ]; then - echo '0 */1 * * * easywi_web cd /home/easywi_web/htdocs && timeout 300 php ./reboot.php >/dev/null 2>&1 -0 */1 * * * easywi_web cd /home/easywi_web/htdocs && timeout 300 php ./reboot.php >/dev/null 2>&1 -*/5 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./statuscheck.php >/dev/null 2>&1 -*/1 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./startupdates.php >/dev/null 2>&1 -*/5 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./jobs.php >/dev/null 2>&1 -*/10 * * * * easywi_web cd /home/easywi_web/htdocs && timeout 290 php ./cloud.php >/dev/null 2>&1' >> /etc/crontab - fi - - service cron restart -fi - -if [ "$INSTALL" == "VS" ]; then - - ps -u $MASTERUSER | grep ts3server | awk '{print $1}' | while read PID; do - kill $PID - done - - if [ -f /home/$MASTERUSER/ts3server_startscript.sh ]; then - rm -rf /home/$MASTERUSER/* - fi - - makeDir /home/$MASTERUSER/ - chmod 750 /home/$MASTERUSER/ - chown -R $MASTERUSER:$MASTERUSER /home/$MASTERUSER - - cd /home/$MASTERUSER/ - - okAndSleep "Scaricando i files del server TS3." - su -c "curl $DOWNLOAD_URL -o teamspeak3-server.tar.bz2" $MASTERUSER - - if [ ! -f teamspeak3-server.tar.bz2 ]; then - errorAndExit "Download fallito! Uscendo ora!" - fi - - okAndSleep "Estraendo i file del serverTS3." - su -c "tar -xf teamspeak3-server.tar.bz2 --strip-components=1" $MASTERUSER - - removeIfExists teamspeak3-server.tar.bz2 - - QUERY_WHITLIST_TXT=/home/$MASTERUSER/query_ip_whitelist.txt - - if [ ! -f $QUERY_WHITLIST_TXT ]; then - touch $QUERY_WHITLIST_TXT - chown $MASTERUSER:$MASTERUSER $QUERY_WHITLIST_TXT - fi - - if [ -f $QUERY_WHITLIST_TXT ]; then - - if [ "`grep '127.0.0.1' $QUERY_WHITLIST_TXT`" == "" ]; then - echo "127.0.0.1" >> $QUERY_WHITLIST_TXT - fi - - if [ "$LOCAL_IP" != "" ]; then - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $LOCAL_IP`" != "" -a "`grep $LOCAL_IP $QUERY_WHITLIST_TXT`" == "" ]; then - echo $LOCAL_IP >> $QUERY_WHITLIST_TXT - fi - fi - - cyanMessage " " - cyanMessage "Please specify the IPv4 address of the Easy-WI web panel." - read IP_ADDRESS - - if [ "$IP_ADDRESS" != "" ]; then - if [ "`grep -E '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b' <<< $IP_ADDRESS`" != "" -a "`grep $IP_ADDRESS $QUERY_WHITLIST_TXT`" == "" ]; then - echo $IP_ADDRESS >> $QUERY_WHITLIST_TXT - fi - fi - else - redMessage "Non posso modificare il file $QUERY_WHITLIST_TXT, perfavore mantenerlo manualmente." - fi - - QUERY_PASSWORD=`< /dev/urandom tr -dc A-Za-z0-9 | head -c12` - - greenMessage "Avviando il server TS3 per la prima volta e e chiudendolo ancora per rendere la password visibile nell'albero dei processi." - su -c "./ts3server_startscript.sh start serveradmin_password=$QUERY_PASSWORD createinifile=1 inifile=ts3server.ini" $MASTERUSER - runSpinner 25 - su -c "./ts3server_startscript.sh stop" $MASTERUSER - - greenMessage "Avviando il server TS3 permanentemente." - su -c "./ts3server_startscript.sh start inifile=ts3server.ini" $MASTERUSER -fi - -okAndSleep "Rimuovendo i pacchetti non necessari." -apt-get autoremove -y - -if [ "$INSTALL" == "EW" ]; then - - if [ "$SSL" == "Si" ]; then - PROTOCOL="https" - else - PROTOCOL="http" - fi - - greenMessage "L'intallazione del pannello Easy-WI è terminata per quanto riguarda l'architettura. perfavore vai al link $PROTOCOL://$IP_DOMAIN/install/install.php per completare il processo di installazione." - greenMessage "Nome utente e password per il DB sono rispettivamente, Username:\"easy_wi\". La password è:\"$DB_PASSWORD\"." - -elif [ "$INSTALL" == "GS" ]; then - greenMessage "L'installazione del server princiaple per i server di gioco è termniata. Perfavore immetti i dati sovrastanti nel pannello al percorso \"Server Master > Panoramica > Aggiungi\"." -elif [ "$INSTALL" == "VS" ]; then - greenMessage "L'installazione del server princiaple per i server voce è termniata. Perfavore immetti i dati sovrastanti nel pannello al percorso \"Servers Voce > Server princiapli > Aggiungi\"." -elif [ "$INSTALL" == "WR" ]; then - greenMessage "L'installazione del server princiaple per i server web è termniata. Perfavore immetti i dati sovrastanti nel pannello al percorso \"Spazio Web > Server Principali > Aggiungi\"." -fi - -if ([ "$INSTALL" == "MY" ] || [ "$INSTALL" == "WR" -a "$SQL" != "Nessuno" ]); then - greenMessage "L'installazione del server principale MySQL è stata effettuata. Perfavore immetti i dati sovrastanti nel pannello al percorso \"MySQL > Server Principali > Aggiungi\"." -fi - -exit 0 diff --git a/server/pswreset.sh b/server/pswreset.sh deleted file mode 100644 index 5258f684..00000000 --- a/server/pswreset.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Author: Ulrich Block -# -# This file is part of Easy-WI. -# -# Easy-WI is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Easy-WI is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Easy-WI. If not, see . -# -# Diese Datei ist Teil von Easy-WI. -# -# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen -# der GNU General Public License, wie von der Free Software Foundation, -# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren -# veroeffentlichten Version, weiterverbreiten und/oder modifizieren. -# -# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber -# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite -# Gewährleistung der MARKTFAEHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. -# Siehe die GNU General Public License fuer weitere Details. -# -# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -# Programm erhalten haben. Wenn nicht, siehe . -# -# Zum installieren: -# chmod 755 /etc/init.d/password -# update-rc.d password defaults -# -# Zum enfernen: -# update-rc.d -f password remove -# rm /etc/init.d/password -# bei https --no-check-certificate als zusaetzlicher Paramter -if [[ "$1" == "start" ]]; then - #cd /home/easy-wi - #su easy-wi -c ./control - #rm control.* - sleep 60 - STRING=`wget --no-check-certificate -q -O - https://wi.domain.de/get_password.php | sed 's/^\xef\xbb\xbf//g'` - PASSWORD=`echo $STRING | awk -F ':' '{print $1}'` - if ([[ "$PASSWORD" != "" ]] && [[ "$PASSWORD" != "old" ]]); then - /usr/sbin/usermod -p `perl -e 'print crypt("'$PASSWORD'","Sa")'` root - fi - #LICENCE=`echo $STRING | awk -F ':' '{print $2}'` - #if ([[ "$LICENCE" != "" ]] && [[ "$LICENCE" != "old" ]]); then - # echo "$LICENCE" > /path/to/licencefile - # chmod 000 /path/to/licencefile - # chown username:gruppe /path/to/licencefile - #fi - update-rc.d -f password remove - rm /etc/init.d/password -fi \ No newline at end of file diff --git a/server/shell_wrapper_scripts/shootmania/MPAseco.sh b/server/shell_wrapper_scripts/shootmania/MPAseco.sh deleted file mode 100644 index efb9c2f3..00000000 --- a/server/shell_wrapper_scripts/shootmania/MPAseco.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -########################################################### -# # -# ========================================= # -# | DNW Despe Networks | # -# ========================================= # -# |>>>>>>>> MPaseco Startscript v2 >>>| # -# |>>>>>>>> http://www.despe.de >>>>>>>>>>| # -# |>>>>>>>> DO NOT EDIT, only if u know >>| # -# |>>>>>>>> what are you doing! >>>>>>>>>>| # -# ========================================= # -# more info: https://github.com/ManiaAseco/MPAseco # -########################################################### - -######################################################################### -# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! # -######################################################################### - -NAME="MPAseco" -PIDFILE="mpaseco.pid" - -# Absolute path to this script, e.g. /home/user/bin/foo.sh -#SCRIPT=$(readlink -f $0) -# Absolute path this script is in, thus /home/user/bin -#SCRIPTPATH=$(dirname $SCRIPT) -#SCRIPTPATH=$(dirname "$(readlink -fn "$0")") -SCRIPTPATH=$PWD/servercontroller -cd $SCRIPTPATH - -######################################################################### -# ONLY FOR DNW - SUPPORT !!! # -######################################################################### - -function start { - echo "Starting $NAME ..." - if test -f $SCRIPTPATH/$PIDFILE; - then - echo "PID file exists, Restart?" - elif test $SCRIPTPATH/$PIDFILE; - then - echo "PID file not exists..." - #touch $PIDFILE - fi - php mpaseco.php SM mpaseco2.log 2>&1 & echo $! > $SCRIPTPATH/$PIDFILE - sleep 1 - PID="`cat $SCRIPTPATH/$PIDFILE`" - echo "...$NAME started. ID $PID" -} -################### - -function stop { - PID="`cat $SCRIPTPATH/$PIDFILE`" - kill $PID - echo "$NAME stopped. ID $PID" - rm -f $SCRIPTPATH/$PIDFILE - echo "$PIDFILE removed" -} - -################### - -case "$1" in - start) - start - ;; - - stop) - stop - ;; - - restart) - stop - sleep 2 - start - ;; - - status) - if [ -f $SCRIPTPATH/$PIDFILE ]; then - PID="`cat $SCRIPTPATH/$PIDFILE`" - echo "$NAME is runing! ID $PID . Server offline? Restart?" - else - echo 'MPAseco has crashed or is stopped incorrect.' - fi - ;; - - - -*) - echo "Usage: $0 {start|stop|restart|status}" -;; - -esac -exit 0 diff --git a/server/shell_wrapper_scripts/shootmania/ShootmaniaServer.sh b/server/shell_wrapper_scripts/shootmania/ShootmaniaServer.sh deleted file mode 100644 index a5a73ea4..00000000 --- a/server/shell_wrapper_scripts/shootmania/ShootmaniaServer.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -########################################################### -# # -# ========================================= # -# | DNW Despe Networks | # -# ========================================= # -# |>>>>>>>> ManiaPlanet Startscript v3 >>>| # -# |>>>>>>>> http://www.despe.de >>>>>>>>>>| # -# |>>>>>>>> DO NOT EDIT, only if u know >>| # -# |>>>>>>>> what are you doing! >>>>>>>>>>| # -# ========================================= # -# # -########################################################### - -######################################################################### -# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! # -######################################################################### - - -# Start ManiaPlanet-Server for TrackMania or ShootMania and start a ServerController - - -if [ "$5" = "/mpaseco" ] - then - ./MPAseco.sh restart & ./ManiaPlanetServer $1 $2 $3 $4 $6 $7 - - elif [ "$5" != "/mpaseco" ] - then - ./ManiaPlanetServer $1 $2 $3 $4 $5 $6 -fi diff --git a/server/shell_wrapper_scripts/starbound/linux64/starbound_server.sh b/server/shell_wrapper_scripts/starbound/linux64/starbound_server.sh deleted file mode 100644 index 7bc2437a..00000000 --- a/server/shell_wrapper_scripts/starbound/linux64/starbound_server.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# Modified by: Ulrich Block -# We need the $@ to be able to send commands to the server binary - -cd "$(dirname "$0")" - -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./ ./starbound_server $@ diff --git a/server/shell_wrapper_scripts/trackmania/TrackmaniaServer.sh b/server/shell_wrapper_scripts/trackmania/TrackmaniaServer.sh deleted file mode 100644 index 862f6104..00000000 --- a/server/shell_wrapper_scripts/trackmania/TrackmaniaServer.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -########################################################### -# # -# ========================================= # -# | DNW Despe Networks | # -# ========================================= # -# |>>>>>>>> ManiaPlanet Startscript v3 >>>| # -# |>>>>>>>> http://www.despe.de >>>>>>>>>>| # -# |>>>>>>>> DO NOT EDIT, only if u know >>| # -# |>>>>>>>> what are you doing! >>>>>>>>>>| # -# ========================================= # -# # -########################################################### - -######################################################################### -# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! # -######################################################################### - - -# Start ManiaPlanet-Server for TrackMania or ShootMania and start a ServerController - - -if [ "$5" = "/xaseco" ] - then - ./XAseco2.sh restart & ./ManiaPlanetServer $1 $2 $3 $4 $6 $7 - - elif [ "$5" != "/xaseco" ] - then - ./ManiaPlanetServer $1 $2 $3 $4 $5 $6 -fi diff --git a/server/shell_wrapper_scripts/trackmania/XAseco2.sh b/server/shell_wrapper_scripts/trackmania/XAseco2.sh deleted file mode 100644 index e121cfd9..00000000 --- a/server/shell_wrapper_scripts/trackmania/XAseco2.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -########################################################### -# # -# ========================================= # -# | DNW Despe Networks | # -# ========================================= # -# |>>>>>>>> XAseco Startscript v3 >>>| # -# |>>>>>>>> http://www.despe.de >>>>>>>>>>| # -# |>>>>>>>> DO NOT EDIT, only if u know >>| # -# |>>>>>>>> what are you doing! >>>>>>>>>>| # -# ========================================= # -# more info: http://www.xaseco.org/ # -########################################################### - -######################################################################### -# DONT EDIT BELOW THIS LINE!!! Broken Server is the reason !!! # -######################################################################### - -NAME="XAseco" -PIDFILE="xaseco2.pid" - -# Absolute path to this script, e.g. /home/user/bin/foo.sh -#SCRIPT=$(readlink -f $0) -# Absolute path this script is in, thus /home/user/bin -#SCRIPTPATH=$(dirname $SCRIPT) -#SCRIPTPATH=$(dirname "$(readlink -fn "$0")") -SCRIPTPATH=$PWD/servercontroller -cd $SCRIPTPATH - -######################################################################### -# ONLY FOR DNW - SUPPORT !!! # -######################################################################### - -function start { - echo "Starting $NAME ..." - if test -f $SCRIPTPATH/$PIDFILE; - then - echo "PID file exists, Restart?" - elif test $SCRIPTPATH/$PIDFILE; - then - echo "PID file not exists..." - #touch $PIDFILE - fi - php $SCRIPTPATH/xaseco2.php TM2C xaseco2.log 2>&1 & echo $! > $SCRIPTPATH/$PIDFILE - sleep 1 - PID="`cat $SCRIPTPATH/$PIDFILE`" - echo "...$NAME started. ID $PID" -} -################### - -function stop { - PID="`cat $SCRIPTPATH/$PIDFILE`" - kill $PID - echo "$NAME stopped. ID $PID" - rm -f $SCRIPTPATH/$PIDFILE - echo "$PIDFILE removed" -} - -################### - -case "$1" in - start) - start - ;; - - stop) - stop - ;; - - restart) - stop - sleep 2 - start - ;; - - status) - if [ -f $SCRIPTPATH/$PIDFILE ]; then - PID="`cat $SCRIPTPATH/$PIDFILE`" - echo "$NAME is runing! ID $PID . Server offline? Restart?" - else - echo 'MPAseco has crashed or is stopped incorrect.' - fi - ;; - - - -*) - echo "Usage: $0 {start|stop|restart|status}" -;; - -esac -exit 0 \ No newline at end of file diff --git a/server/updates.sh b/server/updates.sh deleted file mode 100644 index be9fc9fa..00000000 --- a/server/updates.sh +++ /dev/null @@ -1,242 +0,0 @@ -#!/bin/bash - -# Author: Ulrich Block -# -# This file is part of Easy-WI. -# -# Easy-WI is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Easy-WI is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Easy-WI. If not, see . -# -# Diese Datei ist Teil von Easy-WI. -# -# Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen -# der GNU General Public License, wie von der Free Software Foundation, -# Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren -# veroeffentlichten Version, weiterverbreiten und/oder modifizieren. -# -# Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber -# OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite -# Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. -# Siehe die GNU General Public License fuer weitere Details. -# -# Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -# Programm erhalten haben. Wenn nicht, siehe . -# -############################################ -# Moegliche Cronjob Konfiguration -# 25 1 * * * cd ~/ && ./updates.sh mta -# 25 1 * * * cd ~/ && ./updates.sh mms -# 25 1 * * * cd ~/ && ./updates.sh sm -# 15 */1 * * * cd ~/ && ./updates.sh mms_snapshot -# 15 */1 * * * cd ~/ && ./updates.sh mms_dev -# 15 */1 * * * cd ~/ && ./updates.sh sm_snapshot -# 15 */1 * * * cd ~/ && ./updates.sh sm_dev - - -function greenMessage { - echo -e "\\033[32;1m${@}\033[0m" -} - -function cyanMessage { - echo -e "\\033[36;1m${@}\033[0m" -} - -function checkCreateVersionFile { - if [ ! -f "$HOME/versions/$1" ]; then - touch "$HOME/versions/$1" - fi -} - -function checkCreateFolder { - if [ ! -d "$1" -a "$1" != "" ]; then - mkdir -p "$1" - fi -} - -function removeFile { - if [ -f "$1" ]; then - rm -f "$1" - fi -} - -function downloadExtractFile { - - checkCreateFolder "$HOME/$4/$1/" - - cd "$HOME/$4/$1/" - - removeFile "$2" - - wget "$3" - - if [ -f "$2" ]; then - - if [[ `echo $2 | egrep -o 'samp[[:digit:]]{1,}svr.+'` ]]; then - tar xfv "$2" --strip-components=1 - else - tar xfv "$2" - fi - - rm -f "$2" - - moveFilesFolders "$2" "$4" "$1" - - find -type f ! -perm -750 -exec chmod 640 {} \; - find -type d -exec chmod 750 {} \; - fi -} - -function moveFilesFolders { - - FOLDER=`echo $1 | sed -r 's/.tar.gz//g'` - - if [ "$FOLDER" != "" -a "" != "$2" -a "$3" != "" -a -d "$HOME/$2/$3/$FOLDER" ]; then - - cd "$HOME/$2/$3/" - - find "$FOLDER/" -mindepth 1 -type d | while read DIR; do - - NEW_FODLER=${DIR/$FOLDER\//} - - if [ ! -d "$HOME/$2/$3/$NEW_FODLER" ]; then - mkdir -p "$HOME/$2/$3/$NEW_FODLER" - fi - done - - find "$FOLDER/" -type f | while read FILE; do - - MOVE_TO=${FILE/$FOLDER\//.\/} - - if [ "$MOVE_TO" != "" ]; then - mv "$FILE" "$MOVE_TO" - fi - done - - rm -rf "$FOLDER" - fi -} - -function update { - - checkCreateVersionFile "$1" - - FILE_NAME=`echo $2 | egrep -o '((sourcemod|mmsource|multitheftauto_linux|baseconfig)-[[:digit:]]|samp[[:digit:]]{1,}svr.+).*$' | tail -1` - LOCAL_VERSION=`cat $HOME/versions/$1 | tail -1` - CURRENT_VERSION=`echo $2 | egrep -o '((mmsource|sourcemod|multitheftauto_linux|baseconfig)-[0-9a-z.-]{1,}[0-9]|samp[[:digit:]]{1,}svr.+)' | tail -1` - - if ([ "$CURRENT_VERSION" != "$LOCAL_VERSION" -o "$LOCAL_VERSION" == "" ] && [ "$CURRENT_VERSION" != "" ]); then - - greenMessage "Updating $1 from $LOCAL_VERSION to $CURRENT_VERSION. Name of file is $FILE_NAME" - - downloadExtractFile "$3" "$FILE_NAME" "$2" "$4" - echo "$CURRENT_VERSION" > "$HOME/versions/$1" - - elif [ "$CURRENT_VERSION" == "" ]; then - cyanMessage "Could not detect current version for ${1}. Local version is $LOCAL_VERSION." - else - cyanMessage "${1} already up to date. Local version is $LOCAL_VERSION. Most recent version is $CURRENT_VERSION" - fi -} - -function updatesAddonSnapshots { - - if [ "$3" == "" ]; then - cyanMessage "Searching updates for $1 and revision $2" - else - cyanMessage "Searching snapshot updates for $1 ($3) and revision $2" - fi - - if [ "$1" == "sourcemod" ]; then - DOWNLOAD_URL=`lynx -dump "http://www.sourcemod.net/smdrop/$2/" | egrep -o "http:.*sourcemod-.*-linux.*" | tail -2 | head -n 1` - else - DOWNLOAD_URL=`lynx -dump "http://www.metamodsource.net/mmsdrop/$2/" | egrep -o "http:.*mmsource-.*-git.*-linux.*" | tail -1` - fi - - if [ "$3" == "" ]; then - update "${1}.txt" "$DOWNLOAD_URL" "${1}" "masteraddons" - else - update "${1}_snapshot_${3}.txt" "$DOWNLOAD_URL" "${1}-${3}" "masteraddons" - fi -} -function fileUpdate { - - checkCreateVersionFile "$1" - - checkCreateFolder "$HOME/$4/$2" - - cd "$HOME/$4/$2" - - wget "$2" - - NO_HTTP=${2:6} - FILE_NAME=${NO_HTTP##/*/} - - if [ "$FILE_NAME" != "" -a -f "$FILE_NAME" ]; then - - LOCAL_VERSION=`cat $HOME/versions/$1 | tail -1` - CURRENT_VERSION=`stat -c "%Y" $FILE_NAME` - - if ([ "$CURRENT_VERSION" != "$LOCAL_VERSION" -o "$LOCAL_VERSION" == "" ] && [ "$CURRENT_VERSION" != "" ]); then - - greenMessage "Updating $3 from $LOCAL_VERSION to $CURRENT_VERSION. Name of file is $FILE_NAME" - - unzip "$FILE_NAME" - - echo "$CURRENT_VERSION" > "$HOME/versions/$1" - - else - cyanMessage "$3 already up to date. Local version is $LOCAL_VERSION. Most recent version is $CURRENT_VERSION" - fi - - rm -f "$FILE_NAME" - fi -} - -function updateMTA { - - cyanMessage "Searching update for MTA San Andreas" - - DOWNLOAD_URL=`lynx -dump http://linux.mtasa.com/ | egrep -o "http:.*multitheftauto_linux-(.*).tar.gz" | tail -1` - update server_mta.txt "$DOWNLOAD_URL" "mtasa" "masterserver" - - DOWNLOAD_URL=`lynx -dump http://linux.mtasa.com/ | egrep -o "http:.*baseconfig-(.*).tar.gz" | tail -1` - update server_mta_baseconfig.txt "$DOWNLOAD_URL" "mtasa" "masterserver" - - if [ "`date +'%H'`" == "00" ]; then - fileUpdate server_mta_resources.txt "http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip" "mtasa" "masterserver" - fi -} - -function updateSAMP { - - cyanMessage "Searching update for San Andreas Multi Player" - - DOWNLOAD_URL=`lynx -dump "http://files.sa-mp.com/" | egrep -o "http:.*samp.*tar\.gz" | tail -n 1` - update server_samp.txt "$DOWNLOAD_URL" "samp" "masterserver" -} - -checkCreateFolder $HOME/versions - -case $1 in - "mta") updateMTA;; - "samp") updateSAMP;; - "mms") updatesAddonSnapshots "metamod" "1.10" "";; - "mms_snapshot") updatesAddonSnapshots "metamod" "1.10" "dev";; - "mms_dev") updatesAddonSnapshots "metamod" "1.11" "dev";; - "sm") updatesAddonSnapshots "sourcemod" "1.7" "";; - "sm_snapshot") updatesAddonSnapshots "sourcemod" "1.7" "dev";; - "sm_dev") updatesAddonSnapshots "sourcemod" "1.8" "dev";; - *) cyanMessage "Usage: ${0} mta|mms|mms_snapshot|mms_dev|sm|sm_snapshot|sm_dev";; -esac - -exit 0