Merge branch 'develop'

This commit is contained in:
snipe 2017-10-10 12:48:05 -07:00
commit 33497c9811
14 changed files with 555 additions and 231 deletions

View file

@ -8,7 +8,6 @@ APP_URL=null
APP_TIMEZONE='UTC'
APP_LOCALE=en
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
@ -31,7 +30,6 @@ DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null
# --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
# --------------------------------------------
@ -46,14 +44,12 @@ MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=you@example.com
MAIL_REPLYTO_NAME='Snipe-IT'
# --------------------------------------------
# REQUIRED: IMAGE LIBRARY
# This should be gd or imagick
# --------------------------------------------
IMAGE_LIB=gd
# --------------------------------------------
# OPTIONAL: SESSION SETTINGS
# --------------------------------------------
@ -64,14 +60,12 @@ COOKIE_NAME=snipeit_session
COOKIE_DOMAIN=null
SECURE_COOKIES=false
# --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS
# --------------------------------------------
REFERRER_POLICY=same-origin
ENABLE_CSP=false
# --------------------------------------------
# OPTIONAL: CACHE SETTINGS
# --------------------------------------------
@ -79,6 +73,12 @@ CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
# --------------------------------------------
# OPTIONAL: REDIS SETTINGS
# --------------------------------------------
REDIS_HOST=null
REDIS_PASSWORD=null
REDIS_PORT-null
# --------------------------------------------
# OPTIONAL: AWS S3 SETTINGS

View file

@ -69,7 +69,15 @@ class LdapSync extends Command
$results = Ldap::findLdapUsers();
$ldap_ou_locations = Location::whereNotNull('ldap_ou')->get();
// Retrieve locations with a mapped OU, and sort them from the shallowest to deepest OU (see #3993)
$ldap_ou_locations = Location::whereNotNull('ldap_ou')->get()->toArray();
$ldap_ou_lengths = array();
foreach ($ldap_ou_locations as $location) {
$ldap_ou_lengths[] = strlen($location["ldap_ou"]);
}
array_multisort($ldap_ou_lengths, SORT_ASC, $ldap_ou_locations);
if (sizeof($ldap_ou_locations) > 0) {
LOG::debug('Some locations have special OUs set. Locations will be automatically set for users in those OUs.');
@ -99,11 +107,11 @@ class LdapSync extends Command
// Grab subsets based on location-specific DNs, and overwrite location for these users.
foreach ($ldap_ou_locations as $ldap_loc) {
$location_users = Ldap::findLdapUsers($ldap_loc->ldap_ou);
$location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]);
$usernames = array();
for ($i = 0; $i < $location_users["count"]; $i++) {
$location_users[$i]["ldap_location_override"] = true;
$location_users[$i]["location_id"] = $ldap_loc->id;
$location_users[$i]["location_id"] = $ldap_loc["id"];
$usernames[] = $location_users[$i][$ldap_result_username][0];
}
@ -194,7 +202,6 @@ class LdapSync extends Command
} else {
$this->info('User '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was '.strtoupper($summary[$x]['createorupdate']).'.');
}
}
} else if ($this->option('json_summary')) {
$json_summary = [ "error" => false, "error_message" => "", "summary" => $summary ];

View file

@ -46,7 +46,7 @@ class ResetDemoSettings extends Command
$settings->per_page = 20;
$settings->site_name = 'Snipe-IT Asset Management Demo';
$settings->auto_increment_assets = 1;
$settings->logo = 'logo.png';
$settings->logo = 'snipe-logo.png';
$settings->alert_email = 'service@snipe-it.io';
$settings->header_color = null;
$settings->barcode_type = 'QRCODE';

View file

@ -89,6 +89,7 @@ class LocationsController extends Controller
$location->state = Input::get('state');
$location->country = Input::get('country');
$location->zip = Input::get('zip');
$location->ldap_ou = Input::get('ldap_ou');
$location->manager_id = Input::get('manager_id');
$location->user_id = Auth::id();

View file

@ -0,0 +1,99 @@
<?php
namespace App\Policies;
use App\Models\Company;
use App\Models\Category;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class CategoryPolicy
{
use HandlesAuthorization;
public function before(User $user, $category)
{
// Lets move all company related checks here.
if ($category instanceof \App\Models\Category && !Company::isCurrentUserHasAccess($category)) {
return false;
}
// If an admin, they can do all asset related tasks.
if ($user->hasAccess('admin')) {
return true;
}
}
/**
* Determine whether the user can view the category.
*
* @param \App\Models\User $user
* @param \App\Category $category
* @return mixed
*/
public function view(User $user)
{
return $user->hasAccess('categories.view');
}
/**
* Determine whether the user can create categories.
*
* @param \App\Models\User $user
* @return mixed
*/
public function create(User $user)
{
return $user->hasAccess('categories.create');
}
/**
* Determine whether the user can update the category.
*
* @param \App\Models\User $user
* @param \App\Category $category
* @return mixed
*/
public function update(User $user)
{
//
return $user->hasAccess('categories.edit');
}
/**
* Determine whether the user can delete the category.
*
* @param \App\Models\User $user
* @param \App\Category $category
* @return mixed
*/
public function delete(User $user)
{
//
return $user->hasAccess('categories.delete');
}
/**
* Determine whether the user can view the category index.
*
* @param \App\Models\User $user
* @param \App\Models\Category $category
* @return mixed
*/
public function index(User $user)
{
return $user->hasAccess('categories.view');
}
/**
* Determine whether the user can manage the category.
*
* @param \App\Models\User $user
* @param \App\Models\Category $category
* @return mixed
*/
public function manage(User $user)
{
return $user->hasAccess('categories.edit');
}
}

View file

@ -0,0 +1,99 @@
<?php
namespace App\Policies;
use App\Models\Company;
use App\Models\Location;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class LocationPolicy
{
use HandlesAuthorization;
public function before(User $user, $location)
{
// Lets move all company related checks here.
if ($location instanceof \App\Models\Location && !Company::isCurrentUserHasAccess($location)) {
return false;
}
// If an admin, they can do all asset related tasks.
if ($user->hasAccess('admin')) {
return true;
}
}
/**
* Determine whether the user can view the location.
*
* @param \App\Models\User $user
* @param \App\Models\Location $location
* @return mixed
*/
public function view(User $user)
{
return $user->hasAccess('locations.view');
}
/**
* Determine whether the user can create locations.
*
* @param \App\Models\\User $user
* @return mixed
*/
public function create(User $user)
{
return $user->hasAccess('locations.create');
}
/**
* Determine whether the user can update the location.
*
* @param \App\Models\User $user
* @param \App\Models\Location $location
* @return mixed
*/
public function update(User $user)
{
//
return $user->hasAccess('locations.edit');
}
/**
* Determine whether the user can delete the location.
*
* @param \App\Models\User $user
* @param \App\Models\Location $location
* @return mixed
*/
public function delete(User $user)
{
//
return $user->hasAccess('locations.delete');
}
/**
* Determine whether the user can view the location index.
*
* @param \App\Models\User $user
* @param \App\Models\Accessory $location
* @return mixed
*/
public function index(User $user)
{
return $user->hasAccess('locations.view');
}
/**
* Determine whether the user can manage the location.
*
* @param \App\Models\User $user
* @param \App\Models\Location $location
* @return mixed
*/
public function manage(User $user)
{
return $user->hasAccess('locations.edit');
}
}

View file

@ -5,7 +5,9 @@ namespace App\Providers;
use App\Models\Accessory;
use Carbon\Carbon;
use App\Models\Asset;
use App\Models\Location;
use App\Models\Component;
use App\Models\Category;
use App\Models\Consumable;
use App\Models\License;
use App\Models\User;
@ -14,6 +16,8 @@ use App\Policies\AssetPolicy;
use App\Policies\ComponentPolicy;
use App\Policies\ConsumablePolicy;
use App\Policies\LicensePolicy;
use App\Policies\LocationPolicy;
use App\Policies\CategoryPolicy;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
@ -33,6 +37,8 @@ class AuthServiceProvider extends ServiceProvider
Consumable::class => ConsumablePolicy::class,
License::class => LicensePolicy::class,
User::class => UserPolicy::class,
Location::class => LocationPolicy::class,
Category::class => CategoryPolicy::class,
];
/**

View file

@ -29,6 +29,7 @@
"phpdocumentor/reflection-docblock": "3.2.2",
"phpspec/prophecy": "1.6.2",
"pragmarx/google2fa": "^1.0",
"predis/predis": "^1.1",
"schuppo/password-strength": "~1.5",
"spatie/laravel-backup": "^3.0.0",
"tecnickcom/tc-lib-barcode": "^1.15",

273
composer.lock generated
View file

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "0806112cf7a9396f0a7d89649ea7060b",
"hash": "abe6a702f2383ae1fd4c9bbfb06c47ee",
"content-hash": "7659dd61c86bb042a246c2fa313d79a6",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -84,7 +85,7 @@
"s3",
"sdk"
],
"time": "2017-09-29T19:46:41+00:00"
"time": "2017-09-29 19:46:41"
},
{
"name": "aws/aws-sdk-php-laravel",
@ -140,7 +141,7 @@
"s3",
"sdk"
],
"time": "2016-01-18T06:57:07+00:00"
"time": "2016-01-18 06:57:07"
},
{
"name": "barryvdh/laravel-debugbar",
@ -189,7 +190,7 @@
"profiler",
"webprofiler"
],
"time": "2017-07-21T11:56:48+00:00"
"time": "2017-07-21 11:56:48"
},
{
"name": "christian-riesen/base32",
@ -243,7 +244,7 @@
"encode",
"rfc4648"
],
"time": "2016-05-05T11:49:03+00:00"
"time": "2016-05-05 11:49:03"
},
{
"name": "defuse/php-encryption",
@ -306,7 +307,7 @@
"security",
"symmetric key cryptography"
],
"time": "2017-05-18T21:28:48+00:00"
"time": "2017-05-18 21:28:48"
},
{
"name": "dnoegel/php-xdg-base-dir",
@ -339,7 +340,7 @@
"MIT"
],
"description": "implementation of xdg base directory specification for php",
"time": "2014-10-24T07:27:01+00:00"
"time": "2014-10-24 07:27:01"
},
{
"name": "doctrine/annotations",
@ -407,7 +408,7 @@
"docblock",
"parser"
],
"time": "2017-02-24T16:22:25+00:00"
"time": "2017-02-24 16:22:25"
},
{
"name": "doctrine/cache",
@ -477,7 +478,7 @@
"cache",
"caching"
],
"time": "2017-07-22T12:49:21+00:00"
"time": "2017-07-22 12:49:21"
},
{
"name": "doctrine/collections",
@ -544,7 +545,7 @@
"collections",
"iterator"
],
"time": "2017-01-03T10:49:41+00:00"
"time": "2017-01-03 10:49:41"
},
{
"name": "doctrine/common",
@ -617,7 +618,7 @@
"persistence",
"spl"
],
"time": "2017-07-22T08:35:12+00:00"
"time": "2017-07-22 08:35:12"
},
{
"name": "doctrine/dbal",
@ -688,7 +689,7 @@
"persistence",
"queryobject"
],
"time": "2017-07-22T20:44:48+00:00"
"time": "2017-07-22 20:44:48"
},
{
"name": "doctrine/inflector",
@ -755,7 +756,7 @@
"singularize",
"string"
],
"time": "2015-11-06T14:35:42+00:00"
"time": "2015-11-06 14:35:42"
},
{
"name": "doctrine/instantiator",
@ -809,7 +810,7 @@
"constructor",
"instantiate"
],
"time": "2015-06-14T21:17:01+00:00"
"time": "2015-06-14 21:17:01"
},
{
"name": "doctrine/lexer",
@ -863,7 +864,7 @@
"lexer",
"parser"
],
"time": "2014-09-09T13:34:57+00:00"
"time": "2014-09-09 13:34:57"
},
{
"name": "erusev/parsedown",
@ -905,7 +906,7 @@
"markdown",
"parser"
],
"time": "2017-05-14T14:47:48+00:00"
"time": "2017-05-14 14:47:48"
},
{
"name": "fideloper/proxy",
@ -962,7 +963,7 @@
"proxy",
"trusted proxy"
],
"time": "2017-06-15T17:19:42+00:00"
"time": "2017-06-15 17:19:42"
},
{
"name": "firebase/php-jwt",
@ -1005,7 +1006,7 @@
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"time": "2016-07-18T04:51:16+00:00"
"time": "2016-07-18 04:51:16"
},
{
"name": "guzzlehttp/guzzle",
@ -1070,7 +1071,7 @@
"rest",
"web service"
],
"time": "2017-06-22T18:50:49+00:00"
"time": "2017-06-22 18:50:49"
},
{
"name": "guzzlehttp/promises",
@ -1121,7 +1122,7 @@
"keywords": [
"promise"
],
"time": "2016-12-20T10:07:11+00:00"
"time": "2016-12-20 10:07:11"
},
{
"name": "guzzlehttp/psr7",
@ -1186,7 +1187,7 @@
"uri",
"url"
],
"time": "2017-03-20T17:10:46+00:00"
"time": "2017-03-20 17:10:46"
},
{
"name": "intervention/image",
@ -1256,7 +1257,7 @@
"thumbnail",
"watermark"
],
"time": "2017-09-21T16:29:17+00:00"
"time": "2017-09-21 16:29:17"
},
{
"name": "jakub-onderka/php-console-color",
@ -1299,7 +1300,7 @@
"homepage": "http://www.acci.cz"
}
],
"time": "2014-04-08T15:00:19+00:00"
"time": "2014-04-08 15:00:19"
},
{
"name": "jakub-onderka/php-console-highlighter",
@ -1343,7 +1344,7 @@
"homepage": "http://www.acci.cz/"
}
],
"time": "2015-04-20T18:58:01+00:00"
"time": "2015-04-20 18:58:01"
},
{
"name": "javiereguiluz/easyslugger",
@ -1373,7 +1374,7 @@
"MIT"
],
"description": "A fast and easy to use slugger with full UTF-8 support.",
"time": "2015-04-12T19:57:10+00:00"
"time": "2015-04-12 19:57:10"
},
{
"name": "jenssegers/rollbar",
@ -1425,7 +1426,7 @@
"monitoring",
"rollbar"
],
"time": "2017-01-25T08:34:12+00:00"
"time": "2017-01-25 08:34:12"
},
{
"name": "laravel/framework",
@ -1554,7 +1555,7 @@
"framework",
"laravel"
],
"time": "2017-08-30T09:26:16+00:00"
"time": "2017-08-30 09:26:16"
},
{
"name": "laravel/passport",
@ -1618,7 +1619,7 @@
"oauth",
"passport"
],
"time": "2017-07-12T20:03:53+00:00"
"time": "2017-07-12 20:03:53"
},
{
"name": "laravel/tinker",
@ -1681,7 +1682,7 @@
"laravel",
"psysh"
],
"time": "2017-07-13T13:11:05+00:00"
"time": "2017-07-13 13:11:05"
},
{
"name": "laravelcollective/html",
@ -1735,7 +1736,7 @@
],
"description": "HTML and Form Builders for the Laravel Framework",
"homepage": "http://laravelcollective.com",
"time": "2017-08-12T15:52:38+00:00"
"time": "2017-08-12 15:52:38"
},
{
"name": "lcobucci/jwt",
@ -1793,7 +1794,7 @@
"JWS",
"jwt"
],
"time": "2017-09-01T08:23:26+00:00"
"time": "2017-09-01 08:23:26"
},
{
"name": "league/csv",
@ -1850,7 +1851,7 @@
"read",
"write"
],
"time": "2017-07-12T07:18:20+00:00"
"time": "2017-07-12 07:18:20"
},
{
"name": "league/event",
@ -1900,7 +1901,7 @@
"event",
"listener"
],
"time": "2015-05-21T12:24:47+00:00"
"time": "2015-05-21 12:24:47"
},
{
"name": "league/flysystem",
@ -1983,7 +1984,7 @@
"sftp",
"storage"
],
"time": "2017-08-06T17:41:04+00:00"
"time": "2017-08-06 17:41:04"
},
{
"name": "league/oauth2-server",
@ -2060,7 +2061,7 @@
"secure",
"server"
],
"time": "2017-07-11T06:31:36+00:00"
"time": "2017-07-11 06:31:36"
},
{
"name": "maknz/slack",
@ -2109,7 +2110,7 @@
"laravel",
"slack"
],
"time": "2015-06-03T03:35:16+00:00"
"time": "2015-06-03 03:35:16"
},
{
"name": "maximebf/debugbar",
@ -2170,7 +2171,7 @@
"debug",
"debugbar"
],
"time": "2017-01-05T08:46:19+00:00"
"time": "2017-01-05 08:46:19"
},
{
"name": "monolog/monolog",
@ -2248,7 +2249,7 @@
"logging",
"psr-3"
],
"time": "2017-06-19T01:22:40+00:00"
"time": "2017-06-19 01:22:40"
},
{
"name": "mtdowling/cron-expression",
@ -2292,7 +2293,7 @@
"cron",
"schedule"
],
"time": "2017-01-23T04:29:33+00:00"
"time": "2017-01-23 04:29:33"
},
{
"name": "mtdowling/jmespath.php",
@ -2347,7 +2348,7 @@
"json",
"jsonpath"
],
"time": "2016-12-03T22:08:25+00:00"
"time": "2016-12-03 22:08:25"
},
{
"name": "neitanod/forceutf8",
@ -2381,7 +2382,7 @@
],
"description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.",
"homepage": "https://github.com/neitanod/forceutf8",
"time": "2017-05-22T18:50:57+00:00"
"time": "2017-05-22 18:50:57"
},
{
"name": "nesbot/carbon",
@ -2434,7 +2435,7 @@
"datetime",
"time"
],
"time": "2017-01-16T07:55:07+00:00"
"time": "2017-01-16 07:55:07"
},
{
"name": "nikic/php-parser",
@ -2485,7 +2486,7 @@
"parser",
"php"
],
"time": "2017-09-02T17:10:46+00:00"
"time": "2017-09-02 17:10:46"
},
{
"name": "paragonie/random_compat",
@ -2533,7 +2534,7 @@
"pseudorandom",
"random"
],
"time": "2017-09-27T21:40:39+00:00"
"time": "2017-09-27 21:40:39"
},
{
"name": "patchwork/utf8",
@ -2592,7 +2593,7 @@
"utf-8",
"utf8"
],
"time": "2016-05-18T13:57:10+00:00"
"time": "2016-05-18 13:57:10"
},
{
"name": "phpdocumentor/reflection-common",
@ -2646,7 +2647,7 @@
"reflection",
"static analysis"
],
"time": "2017-09-11T18:02:19+00:00"
"time": "2017-09-11 18:02:19"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -2691,7 +2692,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-08-08T06:39:58+00:00"
"time": "2017-08-08 06:39:58"
},
{
"name": "phpdocumentor/type-resolver",
@ -2738,7 +2739,7 @@
"email": "me@mikevanriel.com"
}
],
"time": "2017-06-03T08:32:36+00:00"
"time": "2017-06-03 08:32:36"
},
{
"name": "phpseclib/phpseclib",
@ -2830,7 +2831,7 @@
"x.509",
"x509"
],
"time": "2017-06-05T06:31:10+00:00"
"time": "2017-06-05 06:31:10"
},
{
"name": "phpspec/prophecy",
@ -2893,7 +2894,7 @@
"spy",
"stub"
],
"time": "2016-11-21T14:58:47+00:00"
"time": "2016-11-21 14:58:47"
},
{
"name": "pragmarx/google2fa",
@ -2954,7 +2955,57 @@
"google2fa",
"laravel"
],
"time": "2016-07-18T20:25:04+00:00"
"time": "2016-07-18 20:25:04"
},
{
"name": "predis/predis",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-curl": "Allows access to Webdis when paired with phpiredis",
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"type": "library",
"autoload": {
"psr-4": {
"Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniele Alessandri",
"email": "suppakilla@gmail.com",
"homepage": "http://clorophilla.net"
}
],
"description": "Flexible and feature-complete Redis client for PHP and HHVM",
"homepage": "http://github.com/nrk/predis",
"keywords": [
"nosql",
"predis",
"redis"
],
"time": "2016-06-16 16:22:20"
},
{
"name": "psr/http-message",
@ -3004,7 +3055,7 @@
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
"time": "2016-08-06 14:39:51"
},
{
"name": "psr/log",
@ -3051,7 +3102,7 @@
"psr",
"psr-3"
],
"time": "2016-10-10T12:19:37+00:00"
"time": "2016-10-10 12:19:37"
},
{
"name": "psy/psysh",
@ -3124,7 +3175,7 @@
"interactive",
"shell"
],
"time": "2017-07-29T19:30:02+00:00"
"time": "2017-07-29 19:30:02"
},
{
"name": "ramsey/uuid",
@ -3206,7 +3257,7 @@
"identifier",
"uuid"
],
"time": "2017-09-22T20:46:04+00:00"
"time": "2017-09-22 20:46:04"
},
{
"name": "rollbar/rollbar",
@ -3256,7 +3307,7 @@
"logging",
"monitoring"
],
"time": "2016-07-05T15:50:29+00:00"
"time": "2016-07-05 15:50:29"
},
{
"name": "schuppo/password-strength",
@ -3306,7 +3357,7 @@
"password strength",
"validation"
],
"time": "2016-10-05T09:57:59+00:00"
"time": "2016-10-05 09:57:59"
},
{
"name": "sebastian/comparator",
@ -3370,7 +3421,7 @@
"compare",
"equality"
],
"time": "2017-01-29T09:50:25+00:00"
"time": "2017-01-29 09:50:25"
},
{
"name": "sebastian/diff",
@ -3422,7 +3473,7 @@
"keywords": [
"diff"
],
"time": "2017-05-22T07:24:03+00:00"
"time": "2017-05-22 07:24:03"
},
{
"name": "sebastian/exporter",
@ -3489,7 +3540,7 @@
"export",
"exporter"
],
"time": "2016-11-19T08:54:04+00:00"
"time": "2016-11-19 08:54:04"
},
{
"name": "sebastian/recursion-context",
@ -3542,7 +3593,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-11-19T07:33:16+00:00"
"time": "2016-11-19 07:33:16"
},
{
"name": "spatie/db-dumper",
@ -3592,7 +3643,7 @@
"mysqldump",
"spatie"
],
"time": "2016-06-14T13:23:01+00:00"
"time": "2016-06-14 13:23:01"
},
{
"name": "spatie/laravel-backup",
@ -3655,7 +3706,7 @@
"laravel-backup",
"spatie"
],
"time": "2017-02-18T09:54:12+00:00"
"time": "2017-02-18 09:54:12"
},
{
"name": "swiftmailer/swiftmailer",
@ -3709,7 +3760,7 @@
"mail",
"mailer"
],
"time": "2017-05-01T15:54:03+00:00"
"time": "2017-05-01 15:54:03"
},
{
"name": "symfony/console",
@ -3777,7 +3828,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-09-06T16:40:18+00:00"
"time": "2017-09-06 16:40:18"
},
{
"name": "symfony/css-selector",
@ -3830,7 +3881,7 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:31:54+00:00"
"time": "2017-01-02 20:31:54"
},
{
"name": "symfony/debug",
@ -3886,7 +3937,7 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2017-09-01T13:23:39+00:00"
"time": "2017-09-01 13:23:39"
},
{
"name": "symfony/event-dispatcher",
@ -3949,7 +4000,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/finder",
@ -3998,7 +4049,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/http-foundation",
@ -4051,7 +4102,7 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2017-09-06T17:07:39+00:00"
"time": "2017-09-06 17:07:39"
},
{
"name": "symfony/http-kernel",
@ -4137,7 +4188,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2017-09-11T16:13:23+00:00"
"time": "2017-09-11 16:13:23"
},
{
"name": "symfony/polyfill-mbstring",
@ -4196,7 +4247,7 @@
"portable",
"shim"
],
"time": "2017-06-14T15:44:48+00:00"
"time": "2017-06-14 15:44:48"
},
{
"name": "symfony/polyfill-php56",
@ -4252,7 +4303,7 @@
"portable",
"shim"
],
"time": "2017-06-14T15:44:48+00:00"
"time": "2017-06-14 15:44:48"
},
{
"name": "symfony/polyfill-util",
@ -4304,7 +4355,7 @@
"polyfill",
"shim"
],
"time": "2017-07-05T15:09:33+00:00"
"time": "2017-07-05 15:09:33"
},
{
"name": "symfony/process",
@ -4353,7 +4404,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/psr-http-message-bridge",
@ -4413,7 +4464,7 @@
"http-message",
"psr-7"
],
"time": "2016-09-14T18:37:20+00:00"
"time": "2016-09-14 18:37:20"
},
{
"name": "symfony/routing",
@ -4491,7 +4542,7 @@
"uri",
"url"
],
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/translation",
@ -4556,7 +4607,7 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/var-dumper",
@ -4624,7 +4675,7 @@
"debug",
"dump"
],
"time": "2017-08-27T14:52:21+00:00"
"time": "2017-08-27 14:52:21"
},
{
"name": "tecnickcom/tc-lib-barcode",
@ -4714,7 +4765,7 @@
"tc-lib-barcode",
"upc"
],
"time": "2017-02-12T13:51:39+00:00"
"time": "2017-02-12 13:51:39"
},
{
"name": "tecnickcom/tc-lib-color",
@ -4777,7 +4828,7 @@
"tc-lib-color",
"web"
],
"time": "2017-02-12T12:07:38+00:00"
"time": "2017-02-12 12:07:38"
},
{
"name": "tightenco/ziggy",
@ -4827,7 +4878,7 @@
}
],
"description": "Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.",
"time": "2017-08-23T11:48:08+00:00"
"time": "2017-08-23 11:48:08"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -4874,7 +4925,7 @@
],
"description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.",
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"time": "2016-09-20T12:50:39+00:00"
"time": "2016-09-20 12:50:39"
},
{
"name": "unicodeveloper/laravel-password",
@ -4929,7 +4980,7 @@
"security",
"unicodeveloper"
],
"time": "2017-04-27T07:35:00+00:00"
"time": "2017-04-27 07:35:00"
},
{
"name": "vlucas/phpdotenv",
@ -4979,7 +5030,7 @@
"env",
"environment"
],
"time": "2016-09-01T10:05:43+00:00"
"time": "2016-09-01 10:05:43"
},
{
"name": "watson/validating",
@ -5029,7 +5080,7 @@
"laravel",
"validation"
],
"time": "2017-08-25T02:12:38+00:00"
"time": "2017-08-25 02:12:38"
},
{
"name": "webmozart/assert",
@ -5079,7 +5130,7 @@
"check",
"validate"
],
"time": "2016-11-23T20:04:58+00:00"
"time": "2016-11-23 20:04:58"
},
{
"name": "zendframework/zend-diactoros",
@ -5131,7 +5182,7 @@
"psr",
"psr-7"
],
"time": "2017-09-13T14:47:08+00:00"
"time": "2017-09-13 14:47:08"
}
],
"packages-dev": [
@ -5192,7 +5243,7 @@
"gherkin",
"parser"
],
"time": "2016-10-30T11:50:56+00:00"
"time": "2016-10-30 11:50:56"
},
{
"name": "codeception/codeception",
@ -5286,7 +5337,7 @@
"functional testing",
"unit testing"
],
"time": "2017-09-28T23:19:49+00:00"
"time": "2017-09-28 23:19:49"
},
{
"name": "facebook/webdriver",
@ -5338,7 +5389,7 @@
"selenium",
"webdriver"
],
"time": "2017-04-28T14:54:49+00:00"
"time": "2017-04-28 14:54:49"
},
{
"name": "fzaninotto/faker",
@ -5388,7 +5439,7 @@
"faker",
"fixtures"
],
"time": "2017-08-15T16:48:10+00:00"
"time": "2017-08-15 16:48:10"
},
{
"name": "myclabs/deep-copy",
@ -5430,7 +5481,7 @@
"object",
"object graph"
],
"time": "2017-04-12T18:52:22+00:00"
"time": "2017-04-12 18:52:22"
},
{
"name": "phpunit/php-code-coverage",
@ -5493,7 +5544,7 @@
"testing",
"xunit"
],
"time": "2017-04-02T07:44:40+00:00"
"time": "2017-04-02 07:44:40"
},
{
"name": "phpunit/php-file-iterator",
@ -5540,7 +5591,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03T07:40:28+00:00"
"time": "2016-10-03 07:40:28"
},
{
"name": "phpunit/php-text-template",
@ -5581,7 +5632,7 @@
"keywords": [
"template"
],
"time": "2015-06-21T13:50:34+00:00"
"time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
@ -5630,7 +5681,7 @@
"keywords": [
"timer"
],
"time": "2017-02-26T11:10:40+00:00"
"time": "2017-02-26 11:10:40"
},
{
"name": "phpunit/php-token-stream",
@ -5679,7 +5730,7 @@
"keywords": [
"tokenizer"
],
"time": "2017-02-27T10:12:30+00:00"
"time": "2017-02-27 10:12:30"
},
{
"name": "phpunit/phpunit",
@ -5761,7 +5812,7 @@
"testing",
"xunit"
],
"time": "2017-09-24T07:23:38+00:00"
"time": "2017-09-24 07:23:38"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -5820,7 +5871,7 @@
"mock",
"xunit"
],
"time": "2017-06-30T09:13:00+00:00"
"time": "2017-06-30 09:13:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -5865,7 +5916,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04T06:30:41+00:00"
"time": "2017-03-04 06:30:41"
},
{
"name": "sebastian/environment",
@ -5915,7 +5966,7 @@
"environment",
"hhvm"
],
"time": "2016-11-26T07:53:53+00:00"
"time": "2016-11-26 07:53:53"
},
{
"name": "sebastian/global-state",
@ -5966,7 +6017,7 @@
"keywords": [
"global state"
],
"time": "2015-10-12T03:26:01+00:00"
"time": "2015-10-12 03:26:01"
},
{
"name": "sebastian/object-enumerator",
@ -6012,7 +6063,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-02-18T15:18:39+00:00"
"time": "2017-02-18 15:18:39"
},
{
"name": "sebastian/resource-operations",
@ -6054,7 +6105,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2015-07-28T20:34:47+00:00"
"time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
@ -6097,7 +6148,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03T07:35:21+00:00"
"time": "2016-10-03 07:35:21"
},
{
"name": "squizlabs/php_codesniffer",
@ -6148,7 +6199,7 @@
"phpcs",
"standards"
],
"time": "2017-09-19T22:47:14+00:00"
"time": "2017-09-19 22:47:14"
},
{
"name": "stecman/symfony-console-completion",
@ -6193,7 +6244,7 @@
}
],
"description": "Automatic BASH completion for Symfony Console Component based applications.",
"time": "2016-02-24T05:08:54+00:00"
"time": "2016-02-24 05:08:54"
},
{
"name": "symfony/browser-kit",
@ -6250,7 +6301,7 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
},
{
"name": "symfony/dom-crawler",
@ -6306,7 +6357,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-01-21T17:13:55+00:00"
"time": "2017-01-21 17:13:55"
},
{
"name": "symfony/yaml",
@ -6361,7 +6412,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:54:42+00:00"
"time": "2017-07-29 21:54:42"
}
],
"aliases": [],

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AllowNullableDepreciationIdInModels extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('models', function (Blueprint $table) {
$table->integer('depreciation_id')->nullable()->default(null)->change();
});
Schema::table('licenses', function (Blueprint $table) {
$table->integer('depreciation_id')->nullable()->default(null)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -398,31 +398,8 @@ Form::macro('time_display_format', function ($name = "time_display_format", $sel
/**
* Barcode macro
* Generates the dropdown menu of available barcodes
* Generates the dropdown menu of available 1D barcodes
*/
Form::macro('barcode_types', function ($name = "barcode_type", $selected = null, $class = null) {
$barcode_types = array(
'QRCODE'=>"QR Code",
'PDF417'=>'PDF417',
'DATAMATRIX'=>'DATAMATRIX',
'C128'=>'Code 128'
);
$select = '<select name="'.$name.'" class="'.$class.'">';
foreach ($barcode_types as $code => $codename) {
$select .= '<option value="'.$code.'"'.($selected == $code ? ' selected="selected"' : '').'>'.$codename.'</option> ';
}
$select .= '</select>';
return $select;
});
Form::macro('alt_barcode_types', function ($name = "alt_barcode", $selected = null, $class = null) {
$barcode_types = array(
@ -445,6 +422,10 @@ Form::macro('alt_barcode_types', function ($name = "alt_barcode", $selected = nu
});
/**
* Barcode macro
* Generates the dropdown menu of available 2D barcodes
*/
Form::macro('barcode_types', function ($name = "barcode_type", $selected = null, $class = null) {
$barcode_types = array(

View file

@ -29,7 +29,7 @@
<span class="btn btn-info fileinput-button">
<span>Select Import File...</span>
<!-- The file input field used as target for the file upload widget -->
<input id="fileupload" type="file" name="files[]" data-url="/api/v1/imports" accept="text/csv">
<input id="fileupload" type="file" name="files[]" data-url="{{ route('api.imports.index') }}" accept="text/csv">
</span>
</div>
<div class="col-md-9" v-show="progress.visible" style="padding-bottom:20px">

View file

@ -125,7 +125,7 @@
@if ($license->manufacturer)
<tr>
<td>{{ trans('admin/hardware/form.manufacturer') }}</td>
<td>
<td><p style="line-height: 23px;">
@can('view', \App\Models\Manufacturer::class)
<a href="{{ route('manufacturers.show', $license->manufacturer->id) }}">
{{ $license->manufacturer->name }}
@ -135,20 +135,23 @@
@endcan
@if ($license->manufacturer->url)
<br><i class="fa fa-globe"></i> <a href="{{ $license->manufacturer->url }}">{{ $license->manufacturer->url }}</a>
<br><i class="fa fa-globe"></i> <a href="{{ $license->manufacturer->url }}" rel="noopener">{{ $license->manufacturer->url }}</a>
@endif
@if ($license->manufacturer->support_url)
<br><i class="fa fa-life-ring"></i> <a href="{{ $license->manufacturer->support_url }}">{{ $license->manufacturer->support_url }}</a>
<br><i class="fa fa-life-ring"></i>
<a href="{{ $license->manufacturer->support_url }}" rel="noopener">{{ $license->manufacturer->support_url }}</a>
@endif
@if ($license->manufacturer->support_phone)
<br><i class="fa fa-phone"></i> {{ $license->manufacturer->support_phone }}
<br><i class="fa fa-phone"></i>
<a href="tel:{{ $license->manufacturer->support_phone }}">{{ $license->manufacturer->support_phone }}</a>
@endif
@if ($license->manufacturer->support_email)
<br><i class="fa fa-envelope"></i> <a href="mailto:{{ $license->manufacturer->support_email }}">{{ $license->manufacturer->support_email }}</a>
@endif
</p>
</td>
</tr>
@endif

View file

@ -39,14 +39,14 @@ spin[3]="/"
# Debian/Ubuntu friendly f(x)s
progress () {
while kill -0 $pid > /dev/null 2>&1
do
for i in "${spin[@]}"
do
echo -ne "\b$i"
sleep .1
done
echo -n " "
while kill -0 "$pid" > /dev/null 2>&1; do
for i in "${spin[@]}"; do
echo -ne "\b$i"
sleep .1
done
done
echo ""
}
setvhdebian () {
@ -65,7 +65,6 @@ setvhdebian () {
echo " CustomLog /var/log/apache2/access.log combined"
echo "</VirtualHost>"
} >> $apachefile
echo >> $hosts "127.0.0.1 $hostname $fqdn"
log "a2ensite $name.conf"
}
@ -100,30 +99,27 @@ installsnipeit () {
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
echo "* Configuring .env file."
cp $webdir/$name/.env.example $webdir/$name/.env
cp "$webdir/$name/.env.example" "$webdir/$name/.env"
sed -i '1 i\#Created By Snipe-it Installer' $webdir/$name/.env
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$tzone',' $webdir/$name/.env
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' $webdir/$name/.env
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' $webdir/$name/.env
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' $webdir/$name/.env
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' $webdir/$name/.env
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' $webdir/$name/.env
sed -i '1 i\#Created By Snipe-it Installer' "$webdir/$name/.env"
sed -i 's,^\(APP_TIMEZONE=\).*,\1'$tzone',' "$webdir/$name/.env"
sed -i 's,^\(DB_HOST=\).*,\1'localhost',' "$webdir/$name/.env"
sed -i 's,^\(DB_DATABASE=\).*,\1'snipeit',' "$webdir/$name/.env"
sed -i 's,^\(DB_USERNAME=\).*,\1'snipeit',' "$webdir/$name/.env"
sed -i 's,^\(DB_PASSWORD=\).*,\1'$mysqluserpw',' "$webdir/$name/.env"
sed -i 's,^\(APP_URL=\).*,\1'http://$fqdn',' "$webdir/$name/.env"
echo "* Installing and running composer."
cd $webdir/$name/
cd "$webdir/$name/"
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --prefer-source
echo "* Setting permissions."
chmod_dirs=( "$webdir/$name/storage" )
chmod_dirs+=( "$webdir/$name/storage/private_uploads" )
chmod_dirs+=( "$webdir/$name/public/uploads" )
for chmod_dir in "${chmod_dirs[@]}"
do
for chmod_dir in "$webdir/$name/storage" "$webdir/$name/storage/private_uploads" "$webdir/$name/public/uploads"; do
chmod -R 755 "$chmod_dir"
done
chown -R $ownergroup $webdir/$name
chown -R "$ownergroup" "$webdir/$name"
echo "* Generating the application key."
log "php artisan key:generate --force"
@ -135,8 +131,7 @@ installsnipeit () {
(crontab -l ; echo "* * * * * /usr/bin/php $webdir/$name/artisan schedule:run >> /dev/null 2>&1") | crontab -
}
#CentOS Friendly f(x)s
function isinstalled {
isinstalled () {
if yum list installed "$@" >/dev/null 2>&1; then
true
else
@ -144,8 +139,8 @@ function isinstalled {
fi
}
if [ -f /etc/lsb-release ]; then
distro="$(lsb_release -s -i )"
if [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then
distro="$(lsb_release -s -i)"
version="$(lsb_release -s -r)"
codename="$(lsb_release -c -s)"
elif [ -f /etc/os-release ]; then
@ -176,15 +171,15 @@ echo ""
shopt -s nocasematch
case $distro in
*Ubuntu*)
echo " The installer has detected Ubuntu version $version as the OS."
echo " The installer has detected $distro version $version codename $codename."
distro=ubuntu
;;
*Debian*)
echo " The installer has detected Debian version $version as the OS."
echo " The installer has detected $distro version $version codename $codename."
distro=debian
;;
*centos*|*redhat*|*ol*|*rhel*)
echo " The installer has detected $distro version $version as the OS."
echo " The installer has detected $distro version $version."
distro=centos
;;
*)
@ -195,7 +190,7 @@ esac
shopt -u nocasematch
echo -n " Q. What is the FQDN of your server? ($fqdn): "
read fqdn
read -r fqdn
if [ -z "$fqdn" ]; then
fqdn="$(hostname --fqdn)"
fi
@ -205,17 +200,17 @@ echo ""
ans=default
until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do
echo -n " Q. Do you want to automatically create the database user password? (y/n) "
read setpw
read -r setpw
case $setpw in
[yY] | [yY][Ee][Ss] )
mysqluserpw="$(echo `< /dev/urandom tr -dc _A-Za-z-0-9 | head -c16`)"
mysqluserpw="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16; echo)"
echo ""
ans="yes"
;;
[nN] | [n|N][O|o] )
echo -n " Q. What do you want your snipeit user password to be?"
read -s mysqluserpw
read -rs mysqluserpw
echo ""
ans="no"
;;
@ -225,8 +220,6 @@ esac
done
#TODO: Lets not install snipeit application under root
#TODO: Make progress tracker go on the same line of the step being run
#TODO: Progress tracker on each step
case $distro in
debian)
@ -236,15 +229,15 @@ case $distro in
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
echo "* Updating with apt-get update."
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
progress
echo "* Upgrading packages with apt-get upgrade."
echo -n "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
echo -n "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$!
progress
@ -253,6 +246,54 @@ case $distro in
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
echo "* Creating MariaDB Database/User."
echo "* Please Input your MariaDB root password:"
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
installsnipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
elif [[ "$version" =~ ^8 ]]; then
##################################### Install for Debian 8 ##############################################
webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install -y software-properties-common"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db"
log "add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/debian $codename main'"
#PHP7 repository
log "apt-get install -y apt-transport-https"
log "wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg"
echo "deb https://packages.sury.org/php/ $codename main" > /etc/apt/sources.list.d/php.list
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
progress
echo -n "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$!
progress
echo -n "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client php7.1 php7.1-mcrypt php7.1-curl php7.1-mysql php7.1-gd php7.1-ldap php7.1-zip php7.1-mbstring php7.1-xml php7.1-bcmath curl git unzip" & pid=$!
progress
a2enmod rewrite
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
echo "* Securing MariaDB."
@ -268,8 +309,8 @@ case $distro in
log "service apache2 restart"
else
echo "Unsupported Debian version. Version found: " $version
return 1
echo "Unsupported Debian version. Version found: $version"
exit 1
fi
;;
ubuntu)
@ -280,20 +321,19 @@ case $distro in
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB repository."
log "apt-get install software-properties-common"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8"
log "add-apt-repository 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu $codename main'"
echo "* Updating with apt-get update."
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
#https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_What_can_be_done_when_the_dpkg_lock_is_held.3F
#[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
progress
echo "* Upgrading packages with apt-get upgrade."
echo -n "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
echo -n "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip" & pid=$!
progress
@ -304,6 +344,9 @@ case $distro in
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
echo "* Starting MariaDB."
log "service mysql start"
@ -326,22 +369,21 @@ case $distro in
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install software-properties-common"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db"
log "add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu $codename main'"
#PHP7 repository
log "add-apt-repository ppa:ondrej/php -y"
echo "* Updating with apt-get update."
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
#https://wiki.debian.org/Teams/Dpkg/FAQ#Q:_What_can_be_done_when_the_dpkg_lock_is_held.3F
#[ -f /var/lib/dpkg/lock ] && rm -f /var/lib/dpkg/lock
progress
echo "* Upgrading packages with apt-get upgrade."
echo -n "* Upgrading packages with apt-get upgrade."
log "apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
echo -n "* Installing Apache httpd, PHP, MariaDB and other requirements."
log "DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server mariadb-client php7.1 php7.1-mcrypt php7.1-curl php7.1-mysql php7.1-gd php7.1-ldap php7.1-zip php7.1-mbstring php7.1-xml php7.1-bcmath curl git unzip" & pid=$!
progress
@ -352,6 +394,9 @@ case $distro in
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
echo "* Starting MariaDB."
log "service mysql start"
@ -368,8 +413,8 @@ case $distro in
log "service apache2 restart"
else
echo "Unsupported Ubuntu version. Version found: " $version
return 1
echo "Unsupported Ubuntu version. Version found: $version"
exit 1
fi
;;
centos)
@ -398,7 +443,7 @@ case $distro in
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml"
for p in $PACKAGES;do
for p in $PACKAGES; do
if isinstalled "$p"; then
echo " * $p already installed"
else
@ -418,15 +463,13 @@ case $distro in
echo "* Please Input your MariaDB root password: "
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
#Create the new virtual host in Apache and enable rewrite
echo "* Creating the new virtual host in Apache."
setvhcentos
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
/sbin/service iptables status >/dev/null 2>&1
if [ $? = 0 ]; then
if /sbin/service iptables status >/dev/null 2>&1; then
echo "* Configuring iptables."
iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT 1 -p tcp -m tcp --dport 443 -j ACCEPT
@ -453,7 +496,7 @@ case $distro in
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml"
for p in $PACKAGES;do
for p in $PACKAGES; do
if isinstalled "$p"; then
echo " * $p already installed"
else
@ -474,7 +517,6 @@ case $distro in
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
#TODO make sure the apachefile doesnt exist isnt already in there
#Create the new virtual host in Apache and enable rewrite
echo "* Creating the new virtual host in Apache."
setvhcentos
@ -498,53 +540,53 @@ case $distro in
log "systemctl restart httpd.service"
else
echo "Unsupported CentOS version. Version found: " $version
return 1
echo "Unsupported CentOS version. Version found: $version"
exit 1
fi
esac
setupmail=default
until [[ $setupmail == "yes" ]] || [[ $setupmail == "no" ]]; do
echo -n " Q. Do you want to configure mail server settings? (y/n) "
read setupmail
read -r setupmail
case $setupmail in
[yY] | [yY][Ee][Ss] )
echo -n " Outgoing mailserver address:"
read mailhost
sed -i 's,^\(MAIL_HOST=\).*,\1'$mailhost',' $webdir/$name/.env
read -r mailhost
sed -i 's,^\(MAIL_HOST=\).*,\1'$mailhost',' "$webdir/$name/.env"
echo -n " Server port number:"
read mailport
sed -i 's,^\(MAIL_PORT=\).*,\1'$mailport',' $webdir/$name/.env
read -r mailport
sed -i 's,^\(MAIL_PORT=\).*,\1'$mailport',' "$webdir/$name/.env"
echo -n " Username:"
read mailusername
sed -i 's,^\(MAIL_USERNAME=\).*,\1'$mailusername',' $webdir/$name/.env
read -r mailusername
sed -i 's,^\(MAIL_USERNAME=\).*,\1'$mailusername',' "$webdir/$name/.env"
echo -n " Password:"
read mailpassword
sed -i 's,^\(MAIL_PASSWORD=\).*,\1'$mailpassword',' $webdir/$name/.env
read -rs mailpassword
sed -i 's,^\(MAIL_PASSWORD=\).*,\1'$mailpassword',' "$webdir/$name/.env"
echo -n " Encryption(null/TLS/SSL):"
read mailencryption
sed -i 's,^\(MAIL_ENCRYPTION=\).*,\1'$mailencryption',' $webdir/$name/.env
read -r mailencryption
sed -i 's,^\(MAIL_ENCRYPTION=\).*,\1'$mailencryption',' "$webdir/$name/.env"
echo -n " From address:"
read mailfromaddr
sed -i 's,^\(MAIL_FROM_ADDR=\).*,\1'$mailfromaddr',' $webdir/$name/.env
read -r mailfromaddr
sed -i 's,^\(MAIL_FROM_ADDR=\).*,\1'$mailfromaddr',' "$webdir/$name/.env"
echo -n " From name:"
read mailfromname
sed -i 's,^\(MAIL_FROM_NAME=\).*,\1'$mailfromname',' $webdir/$name/.env
read -r mailfromname
sed -i 's,^\(MAIL_FROM_NAME=\).*,\1'$mailfromname',' "$webdir/$name/.env"
echo -n " Reply to address:"
read mailreplytoaddr
sed -i 's,^\(MAIL_REPLYTO_ADDR=\).*,\1'$mailreplytoaddr',' $webdir/$name/.env
read -r mailreplytoaddr
sed -i 's,^\(MAIL_REPLYTO_ADDR=\).*,\1'$mailreplytoaddr',' "$webdir/$name/.env"
echo -n " Reply to name:"
read mailreplytoname
sed -i 's,^\(MAIL_REPLYTO_NAME=\).*,\1'$mailreplytoname',' $webdir/$name/.env
read -r mailreplytoname
sed -i 's,^\(MAIL_REPLYTO_NAME=\).*,\1'$mailreplytoname',' "$webdir/$name/.env"
setupmail="yes"
;;
[nN] | [n|N][O|o] )