Merge branch 'develop'

# Conflicts:
#	config/version.php
This commit is contained in:
snipe 2018-03-05 20:27:50 -08:00
commit d42361bac1
66 changed files with 14861 additions and 296 deletions

View file

@ -105,3 +105,4 @@ APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
ALLOW_IFRAMING=false
APP_CIPHER=AES-256-CBC
GOOGLE_MAPS_API=
BACKUP_ENV=true

5
.github/stale.yml vendored
View file

@ -6,8 +6,9 @@ daysUntilClose: 7
exemptLabels:
- pinned
- security
- ready for dev
- bounty
- :woman_technologist: ready for dev
- :moneybag: bounty
- :hand: bug
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable

View file

@ -51,6 +51,18 @@ Please see the [translations documentation](https://snipe-it.readme.io/docs/tran
-----
### Libraries, Modules & Related Projects
Since the release of the JSON REST API, several third-party developers have been developing modules and libraries to work with Snipe-IT.
- [Python Module](https://github.com/jbloomer/SnipeIT-PythonAPI) by [@jbloomer](https://github.com/jbloomer)
- [SnipeSharp - .NET module in C#](https://github.com/barrycarey/SnipeSharp) by [@barrycarey](https://github.com/barrycarey)
- [InQRy](https://github.com/Microsoft/InQRy) by [@Microsoft](https://github.com/Microsoft)
As these were created by third-parties, Snipe-IT cannot provide support for these project, and you should contact the developers directly if you need assistance. Additionally, Snipe-IT makes no guarantees as to the reliability, accuracy or maintainability of these libraries. Use at your own risk. :)
-----
### Contributors
Thanks goes to all of these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)) who have helped Snipe-IT get this far:

View file

@ -690,7 +690,7 @@ class Helper
$array['status'] = $status;
$array['messages'] = $messages;
if (($messages) && (count($messages) > 0)) {
if (($messages) && (is_array($messages)) && (count($messages) > 0)) {
$array['messages'] = $messages;
}
($payload) ? $array['payload'] = $payload : $array['payload'] = null;

View file

@ -369,7 +369,7 @@ class AccessoriesController extends Controller
// Check if the accessory exists
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
// Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
}
$accessory = Accessory::find($accessory_user->accessory_id);
@ -387,6 +387,7 @@ class AccessoriesController extends Controller
$data['log_id'] = $logaction->id;
$data['first_name'] = e($user->first_name);
$data['last_name'] = e($user->last_name);
$data['item_name'] = e($accessory->name);
$data['checkin_date'] = e($logaction->created_at);
$data['item_tag'] = '';

View file

@ -56,6 +56,8 @@ class AssetMaintenancesController extends Controller
'start_date',
'completion_date',
'notes',
'asset_tag',
'asset_name',
'user_id'
];
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
@ -65,6 +67,12 @@ class AssetMaintenancesController extends Controller
case 'user_id':
$maintenances = $maintenances->OrderAdmin($order);
break;
case 'asset_tag':
$maintenances = $maintenances->OrderByTag($order);
break;
case 'asset_name':
$maintenances = $maintenances->OrderByAssetName($order);
break;
default:
$maintenances = $maintenances->orderBy($sort, $order);
break;

View file

@ -25,14 +25,20 @@ class ManufacturersController extends Controller
$allowed_columns = ['id','name','url','support_url','support_email','support_phone','created_at','updated_at','image', 'assets_count', 'consumables_count', 'components_count', 'licenses_count'];
$manufacturers = Manufacturer::select(
array('id','name','url','support_url','support_email','support_phone','created_at','updated_at','image')
array('id','name','url','support_url','support_email','support_phone','created_at','updated_at','image', 'deleted_at')
)->withCount('assets')->withCount('licenses')->withCount('consumables')->withCount('accessories');
if ($request->input('deleted')=='true') {
$manufacturers->onlyTrashed();
}
if ($request->has('search')) {
$manufacturers = $manufacturers->TextSearch($request->input('search'));
}
$offset = request('offset', 0);
$limit = $request->input('limit', 50);
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';

View file

@ -10,6 +10,7 @@ use App\Models\Setting;
use Mail;
use App\Notifications\SlackTest;
use Notification;
use App\Notifications\MailTest;
class SettingsController extends Controller
{
@ -132,11 +133,13 @@ class SettingsController extends Controller
{
if (!config('app.lock_passwords')) {
try {
Mail::send('emails.test', [], function ($m) {
Notification::send(Setting::first(), new MailTest());
/*Mail::send('emails.test', [], function ($m) {
$m->to(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.test_email'));
});
});*/
return response()->json(['message' => 'Mail sent to '.config('mail.reply_to.address')], 200);
} catch (Exception $e) {
return response()->json(['message' => $e->getMessage()], 500);

View file

@ -242,6 +242,32 @@ class ManufacturersController extends Controller
return redirect()->route('manufacturers.index')->with('error', $error);
}
/**
* Restore a given Manufacturer (mark as un-deleted)
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.1.15]
* @param int $manufacturers_id
* @return Redirect
*/
public function restore($manufacturers_id)
{
$this->authorize('create', Manufacturer::class);
$manufacturer = Manufacturer::onlyTrashed()->where('id',$manufacturers_id)->first();
if ($manufacturer) {
// Not sure why this is necessary - it shouldn't fail validation here, but it fails without this, so....
$manufacturer->setValidating(false);
if ($manufacturer->restore()) {
return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.restore.success'));
}
return redirect()->back()->with('error', 'Could not restore.');
}
return redirect()->back()->with('error', trans('admin/manufacturers/message.does_not_exist'));
}

View file

@ -22,6 +22,7 @@ use App\Http\Requests\SetupUserRequest;
use App\Http\Requests\ImageUploadRequest;
use App\Http\Requests\SettingsLdapRequest;
use App\Helpers\Helper;
use App\Notifications\FirstAdminNotification;
/**
* This controller handles all actions related to Settings for
@ -186,11 +187,20 @@ class SettingsController extends Controller
$settings->save();
if (Input::get('email_creds')=='1') {
Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
$data = array();
$data['email'] = $user->email;
$data['username'] = $user->username;
$data['first_name'] = $user->first_name;
$data['last_name'] = $user->last_name;
$data['password'] = $user->password;
$user->notify(new FirstAdminNotification($data));
/*Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
$m->to($data['email'], $data['first_name']);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.your_credentials'));
});
});*/
}
@ -386,6 +396,7 @@ class SettingsController extends Controller
$setting->header_color = $request->input('header_color');
$setting->support_footer = $request->input('support_footer');
$setting->footer_text = $request->input('footer_text');
$setting->skin = $request->input('skin');
$setting->show_url_in_emails = $request->input('show_url_in_emails', '0');

View file

@ -34,6 +34,7 @@ use View;
use Illuminate\Http\Request;
use Gate;
use Artisan;
use App\Notifications\WelcomeNotification;
/**
* This controller handles all actions related to Users for
@ -146,13 +147,16 @@ class UsersController extends Controller
$data['email'] = e($request->input('email'));
$data['username'] = e($request->input('username'));
$data['first_name'] = e($request->input('first_name'));
$data['last_name'] = e($request->input('last_name'));
$data['password'] = e($request->input('password'));
Mail::send('emails.send-login', $data, function ($m) use ($user) {
$user->notify(new WelcomeNotification($data));
/* Mail::send('emails.send-login', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
});
});*/
}
return redirect::route('users.index')->with('success', trans('admin/users/message.success.create'));
}
@ -192,15 +196,18 @@ class UsersController extends Controller
// Send the credentials through email
$data = array();
$data['email'] = $request->input('email');
$data['username'] = $request->input('username');
$data['first_name'] = $request->input('first_name');
$data['last_name'] = $request->input('last_name');
$data['last_name'] = e($request->input('last_name'));
$data['password'] = $request->input('password');
Mail::send('emails.send-login', $data, function ($m) use ($user) {
$user->notify(new WelcomeNotification($data));
/*Mail::send('emails.send-login', $data, function ($m) use ($user) {
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
});
});*/
}
return JsonResponse::create($user);
@ -852,16 +859,21 @@ class UsersController extends Controller
// Send the credentials through email
if ($row[3] != '') {
$data = array();
$data['email'] = trim(e($row[4]));
$data['username'] = trim(e($row[2]));
$data['first_name'] = trim(e($row[0]));
$data['last_name'] = trim(e($row[1]));
$data['password'] = $pass;
if ($newuser['email']) {
Mail::send('emails.send-login', $data, function ($m) use ($newuser) {
$user = User::where('username', $row[2])->first();
$user->notify(new WelcomeNotification($data));
/*Mail::send('emails.send-login', $data, function ($m) use ($newuser) {
$m->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']);
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
$m->subject(trans('mail.welcome', ['name' => $newuser['first_name']]));
});
});*/
}
}
}

View file

@ -22,8 +22,19 @@ class AssetMaintenancesTransformer
{
$array = [
'id' => (int) $assetmaintenance->id,
'asset_name' => ($assetmaintenance->asset) ? ['id' => $assetmaintenance->asset->id,'name'=> e($assetmaintenance->asset->name)] : null,
'asset' => ($assetmaintenance->asset) ? [
'id' => (int) $assetmaintenance->asset->id,
'name'=> ($assetmaintenance->asset->name) ? e($assetmaintenance->asset->name) : null,
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
] : null,
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
'location' => ($assetmaintenance->asset->location) ? [
'id' => (int) $assetmaintenance->asset->location->id,
'name'=> e($assetmaintenance->asset->location->name),
] : null,
'notes' => ($assetmaintenance->notes) ? e($assetmaintenance->notes) : null,
'supplier' => ($assetmaintenance->supplier) ? ['id' => $assetmaintenance->supplier->id,'name'=> e($assetmaintenance->supplier->name)] : null,
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),

View file

@ -36,10 +36,12 @@ class ManufacturersTransformer
'accessories_count' => (int) $manufacturer->accessories_count,
'created_at' => Helper::getFormattedDateObject($manufacturer->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($manufacturer->updated_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($manufacturer->deleted_at, 'datetime'),
];
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Manufacturer::class) ? true : false,
'update' => (($manufacturer->deleted_at=='') && (Gate::allows('update', Manufacturer::class))) ? true : false,
'restore' => (($manufacturer->deleted_at!='') && (Gate::allows('create', Manufacturer::class))) ? true : false,
'delete' => (Gate::allows('delete', Manufacturer::class) && ($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->deleted_at=='')) ? true : false,
];

View file

@ -163,13 +163,12 @@ class Accessory extends SnipeModel
*/
public function scopeTextSearch($query, $search)
{
$search = explode('+', $search);
return $query->where(function ($query) use ($search) {
foreach ($search as $search) {
$query->whereHas('category', function ($query) use ($search) {
$query->where('categories.name', 'LIKE', '%'.$search.'%');
$query->where('categories.name', 'LIKE', '%'.$search.'%')
->where('categories.category_type', '=', 'accessory');
})->orWhere(function ($query) use ($search) {
$query->whereHas('company', function ($query) use ($search) {
$query->where('companies.name', 'LIKE', '%'.$search.'%');
@ -182,7 +181,7 @@ class Accessory extends SnipeModel
->orWhere('accessories.model_number', 'LIKE', '%'.$search.'%')
->orWhere('accessories.order_number', 'LIKE', '%'.$search.'%')
->orWhere('accessories.purchase_cost', '=', $search);
}
});
}

View file

@ -177,4 +177,32 @@ class AssetMaintenance extends Model implements ICompanyableChild
->orderBy('users.first_name', $order)
->orderBy('users.last_name', $order);
}
/**
* Query builder scope to order on asset tag
*
* @param Illuminate\Database\Query\Builder $query Query builder instance
* @param text $order Order
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOrderByTag($query, $order)
{
return $query->leftJoin('assets', 'asset_maintenances.asset_id', '=', 'assets.id')
->orderBy('assets.asset_tag', $order);
}
/**
* Query builder scope to order on asset tag
*
* @param Illuminate\Database\Query\Builder $query Query builder instance
* @param text $order Order
*
* @return Illuminate\Database\Query\Builder Modified query builder
*/
public function scopeOrderByAssetName($query, $order)
{
return $query->leftJoin('assets', 'asset_maintenances.asset_id', '=', 'assets.id')
->orderBy('assets.name', $order);
}
}

View file

@ -21,9 +21,7 @@ class Manufacturer extends SnipeModel
'support_email' => 'email|nullable'
);
protected $hidden = ['user_id','deleted_at'];
protected $hidden = ['user_id'];
/**
* Whether the model should inject it's identifier to the unique

View file

@ -180,6 +180,13 @@ class Setting extends Model
return $this->slack_endpoint;
}
public function routeNotificationForMail()
{
// At this point the endpoint is the same for everything.
// In the future this may want to be adapted for individual notifications.
return config('mail.reply_to.address');
}
public static function passwordComplexityRulesSaving($action = 'update')
{
$security_rules = '';

View file

@ -0,0 +1,67 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class FirstAdminNotification extends Notification
{
use Queueable;
private $_data = array();
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(array $content)
{
$this->_data['email'] = $content['email'];
$this->_data['first_name'] = $content['first_name'];
$this->_data['last_name'] = $content['last_name'];
$this->_data['username'] = $content['username'];
$this->_data['password'] = $content['password'];
$this->_data['url'] = url('/');
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ]))
->markdown('notifications.FirstAdmin', $this->_data);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View file

@ -0,0 +1,61 @@
<?php
namespace App\Notifications;
use App\Models\Settings;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class MailTest extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('mail.test_email'))
->markdown('notifications.Test');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View file

@ -0,0 +1,67 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class WelcomeNotification extends Notification
{
use Queueable;
private $_data = array();
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(array $content)
{
$this->_data['email'] = $content['email'];
$this->_data['first_name'] = $content['first_name'];
$this->_data['last_name'] = $content['last_name'];
$this->_data['username'] = $content['username'];
$this->_data['password'] = $content['password'];
$this->_data['url'] = url('/');
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ]))
->markdown('notifications.Welcome', $this->_data);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View file

@ -24,6 +24,7 @@ return [
base_path('storage/private_uploads'),
base_path('storage/oauth-private.key'),
base_path('storage/oauth-public.key'),
(env('BACKUP_ENV')=='true') ? base_path('.env') : '',
],
/*

View file

@ -1,10 +1,10 @@
<?php
return array (
'app_version' => 'v4.1.14',
'full_app_version' => 'v4.1.14 - build 3408-ga705c71',
'build_version' => '3408',
'full_app_version' => 'v4.1.14 - build 3416-g14af95001',
'build_version' => '3416',
'prerelease_version' => '',
'hash_version' => 'ga705c71',
'full_hash' => 'v4.1.14-17-ga705c71',
'hash_version' => 'g14af95001',
'full_hash' => 'v4.1.14-25-g14af95001',
'branch' => 'master',
);

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddThemeToSettings extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->char('skin')->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('skin');
});
}
}

14132
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -15,6 +15,11 @@ return array(
'success' => 'Manufacturer updated successfully.'
),
'restore' => array(
'error' => 'Manufacturer was not restored, please try again',
'success' => 'Manufacturer restored successfully.'
),
'delete' => array(
'confirm' => 'Are you sure you wish to delete this manufacturer?',
'error' => 'There was an issue deleting the manufacturer. Please try again.',

View file

@ -175,8 +175,11 @@
'select_company' => 'Select Company',
'select_asset' => 'Select Asset',
'settings' => 'Settings',
'show_deleted' => 'Show Deleted',
'show_current' => 'Show Current',
'sign_in' => 'Sign in',
'signature' => 'Signature',
'skin' => 'Skin',
'some_features_disabled' => 'DEMO MODE: Some features are disabled for this installation.',
'site_name' => 'Site Name',
'state' => 'State',

View file

@ -511,3 +511,24 @@ Form::macro('customfield_elements', function ($name = "customfield_elements", $s
return $select;
});
Form::macro('skin', function ($name = "skin", $selected = null, $class = null) {
$formats = array(
'' => 'Default Blue',
'green-dark' => 'Green Dark',
'red-dark' => 'Red Dark',
'orange-dark' => 'Orange Dark',
);
$select = '<select name="'.$name.'" class="'.$class.'" style="width: 250px">';
foreach ($formats as $format => $label) {
$select .= '<option value="'.$format.'"'.($selected == $format ? ' selected="selected"' : '').'>'.$label.'</option> '."\n";
}
$select .= '</select>';
return $select;
});

View file

@ -42,8 +42,10 @@
<tr>
<th data-sortable="true" data-field="id" data-visible="true">{{ trans('general.id') }}</th>
<th data-field="company" data-sortable="false" data-visible="true">{{ trans('admin/companies/table.title') }}</th>
<th data-sortable="false" data-visible="true" data-field="asset_name" data-formatter="hardwareLinkObjFormatter">{{ trans('admin/asset_maintenances/table.asset_name') }}</th>
<th data-sortable="false" data-visible="true" data-field="supplier" data-formatter="suppliersLinkObjFormatter">{{ trans('general.supplier') }}</th>
<th data-sortable="true" data-visible="false" data-field="asset_name" data-formatter="assetNameLinkFormatter">{{ trans('admin/asset_maintenances/table.asset_name') }}</th>
<th data-field="asset_tag" data-sortable="true" data-visible="true" data-formatter="assetTagLinkFormatter">{{ trans('admin/hardware/table.asset_tag') }}</th>
<th data-sortable="false" data-visible="true" data-field="location" data-formatter="locationsLinkObjFormatter">{{ trans('admin/hardware/table.location') }}</th>
<th data-sortable="false" data-visible="true" data-field="supplier" data-formatter="suppliersLinkObjFormatter">{{ trans('general.supplier') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="asset_maintenance_type">{{ trans('admin/asset_maintenances/form.asset_maintenance_type') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="title">{{ trans('admin/asset_maintenances/form.title') }}</th>
<th data-searchable="true" data-visible="true" data-sortable="true" data-field="start_date" data-formatter="dateDisplayFormatter">{{ trans('admin/asset_maintenances/form.start_date') }}</th>

View file

@ -541,7 +541,13 @@
@foreach ($asset->licenseseats as $seat)
<tr>
<td><a href="{{ route('licenses.show', $seat->license->id) }}">{{ $seat->license->name }}</a></td>
<td>{{ $seat->license->serial }}</td>
<td>
@can('viewKeys', $seat->license)
{!! nl2br(e($seat->license->serial)) !!}
@else
------------
@endcan
</td>
<td>
<a href="{{ route('licenses.checkin', $seat->id) }}" class="btn btn-sm bg-purple" data-tooltip="true">{{ trans('general.checkin') }}</a>
</td>

View file

@ -31,30 +31,33 @@
</script>
@if (($snipeSettings) && ($snipeSettings->skin!=''))
<link rel="stylesheet" href="{{ url('css/skins/skin-'.$snipeSettings->skin) }}.css">
@endif
<style nonce="{{ csrf_token() }}">
@if ($snipeSettings)
@if ($snipeSettings->header_color)
.main-header .navbar, .main-header .logo {
background-color: {{ $snipeSettings->header_color }};
background: -webkit-linear-gradient(top, {{ $snipeSettings->header_color }} 0%,{{ $snipeSettings->header_color }} 100%);
background: linear-gradient(to bottom, {{ $snipeSettings->header_color }} 0%,{{ $snipeSettings->header_color }} 100%);
border-color: {{ $snipeSettings->header_color }};
}
.skin-blue .sidebar-menu > li:hover > a, .skin-blue .sidebar-menu > li.active > a {
border-left-color: {{ $snipeSettings->header_color }};
}
@if (($snipeSettings) && ($snipeSettings->header_color!=''))
.main-header .navbar, .main-header .logo {
background-color: {{ $snipeSettings->header_color }};
background: -webkit-linear-gradient(top, {{ $snipeSettings->header_color }} 0%,{{ $snipeSettings->header_color }} 100%);
background: linear-gradient(to bottom, {{ $snipeSettings->header_color }} 0%,{{ $snipeSettings->header_color }} 100%);
border-color: {{ $snipeSettings->header_color }};
}
.skin-blue .sidebar-menu > li:hover > a, .skin-blue .sidebar-menu > li.active > a {
border-left-color: {{ $snipeSettings->header_color }};
}
.btn-primary {
background-color: {{ $snipeSettings->header_color }};
border-color: {{ $snipeSettings->header_color }};
}
.btn-primary {
background-color: {{ $snipeSettings->header_color }};
border-color: {{ $snipeSettings->header_color }};
}
@endif
@endif
@if ($snipeSettings->custom_css)
@if (($snipeSettings) && ($snipeSettings->custom_css!=''))
{!! $snipeSettings->show_custom_css() !!}
@endif
@endif
@media (max-width: 400px) {
.navbar-left {
margin: 2px;

View file

@ -12,6 +12,14 @@
<a href="{{ route('manufacturers.create') }}" class="btn btn-primary pull-right">
{{ trans('general.create') }}</a>
@endcan
@if (Input::get('deleted')=='true')
<a class="btn btn-default pull-right" href="{{ route('manufacturers.index') }}" style="margin-right: 5px;">{{ trans('general.show_current') }}</a>
@else
<a class="btn btn-default pull-right" href="{{ route('manufacturers.index', ['deleted' => 'true']) }}" style="margin-right: 5px;">
{{ trans('general.show_deleted') }}</a>
@endif
@stop
{{-- Page content --}}
@ -37,7 +45,7 @@
data-sort-order="asc"
id="manufacturersTable"
class="table table-striped snipe-table"
data-url="{{route('api.manufacturers.index') }}"
data-url="{{route('api.manufacturers.index', ['deleted' => e(Input::get('deleted')) ]) }}"
data-export-options='{
"fileName": "export-manufacturers-{{ date('Y-m-d') }}",
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]

View file

@ -0,0 +1,17 @@
@component('mail::message')
{{ trans('mail.hello') }} {{ $first_name }} {{$last_name}},
{{ trans('mail.login') }} {{ $username }} <br>
{{ trans('mail.password') }} {{ $password }}
@component('mail::button', ['url' => $url])
Go To {{$snipeSettings->site_name}}
@endcomponent
{{ trans('mail.best_regards') }} <br>
@if ($snipeSettings->show_url_in_emails=='1')
<p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>
@else
<p>{{ $snipeSettings->site_name }}</p>
@endif
@endcomponent

View file

@ -0,0 +1,11 @@
@component('mail::message')
{{ trans('mail.test_mail_text') }}
Thanks,<br>
@if ($snipeSettings->show_url_in_emails=='1')
<p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>
@else
<p>{{ $snipeSettings->site_name }}</p>
@endif
@endcomponent

View file

@ -0,0 +1,19 @@
@component('mail::message')
{{ trans('mail.hello') }} {{ $first_name }} {{$last_name}},
{{ trans('mail.admin_has_created', ['web' => $snipeSettings->site_name]) }}
{{ trans('mail.login') }} {{ $username }} <br>
{{ trans('mail.password') }} {{ $password }}
@component('mail::button', ['url' => $url])
Go To {{$snipeSettings->site_name}}
@endcomponent
{{ trans('mail.best_regards') }} <br>
@if ($snipeSettings->show_url_in_emails=='1')
<p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>
@else
<p>{{ $snipeSettings->site_name }}</p>
@endif
@endcomponent

View file

@ -413,6 +413,17 @@
return '<a href="{{ url('/') }}/admin/groups/' + row.id + '"> ' + value + '</a>';
}
function assetTagLinkFormatter(value, row) {
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
}
function assetNameLinkFormatter(value, row) {
if ((row.asset) && (row.asset.name)) {
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.name + '</a>';
}
}
function trueFalseFormatter(value, row) {
if ((value) && ((value == 'true') || (value == '1'))) {
return '<i class="fa fa-check text-success"></i>';

View file

@ -120,6 +120,18 @@
</div>
</div>
<!-- Email format -->
<div class="form-group {{ $errors->has('skin') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('skin', trans('general.skin')) }}
</div>
<div class="col-md-9">
{!! Form::skin('skin', Input::old('skin', $setting->skin), 'select2') !!}
{!! $errors->first('skin', '<span class="alert-msg">:message</span>') !!}
</div>
</div>
<!-- Custom css -->
<div class="form-group {{ $errors->has('custom_css') ? 'error' : '' }}">
<div class="col-md-3">

View file

@ -36,16 +36,15 @@
<i class="fa fa-wrench"></i> {{ trans('admin/settings/general.general_settings') }}
</h4>
</div>
<div class="box-body">
<div class="box-body">
<div class="col-md-12">
<!-- Full Multiple Companies Support -->
<div class="form-group {{ $errors->has('full_multiple_companies_support') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('full_multiple_companies_support',
trans('admin/settings/general.full_multiple_companies_support_text')) }}
{{ Form::label('full_multiple_companies_support', trans('admin/settings/general.full_multiple_companies_support_text')) }}
</div>
<div class="col-md-9">
{{ Form::checkbox('full_multiple_companies_support', '1', Input::old('full_multiple_companies_support', $setting->full_multiple_companies_support),array('class' => 'minimal')) }}
@ -56,6 +55,7 @@
</p>
</div>
</div>
<!-- /.form-group -->
<!-- Require signature for acceptance -->
@ -251,6 +251,7 @@
</div>
</div>
<!-- /.form-group -->
</div>
</div> <!--/.box-body-->
<div class="box-footer">
@ -263,6 +264,7 @@
</div>
</div>
</div> <!-- /box -->
</div> <!-- /.col-md-8-->
</div> <!-- /.row-->

View file

@ -21,6 +21,10 @@
width: 100% !important;
}
}
.logo {
width:50px;
height:50px;
}
</style>
<table class="wrapper" width="100%" cellpadding="0" cellspacing="0">

View file

@ -2,7 +2,23 @@
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@if($snipeSettings::setupCompleted())
@if ($snipeSettings->brand == '3')
@if ($snipeSettings->logo!='')
<img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
{{ $snipeSettings->site_name }}
@elseif ($snipeSettings->brand == '2')
@if ($snipeSettings->logo!='')
<img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
@else
{{ $snipeSettings->site_name }}
@endif
@else
Snipe-it
@endif
@endcomponent
@endslot
@ -21,7 +37,11 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
&copy; {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@if($snipeSettings::setupCompleted())
© {{ date('Y') }} {{ $snipeSettings->site_name }}. All rights reserved.
@else
© {{ date('Y') }} Snipe-it. All rights reserved.
@endif
@endcomponent
@endslot
@endcomponent

View file

@ -2,7 +2,23 @@
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@if($snipeSettings::setupCompleted())
@if ($snipeSettings->brand == '3')
@if ($snipeSettings->logo!='')
<img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
{{ $snipeSettings->site_name }}
@elseif ($snipeSettings->brand == '2')
@if ($snipeSettings->logo!='')
<img class="navbar-brand-img logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
@else
{{ $snipeSettings->site_name }}
@endif
@else
Snipe-it
@endif
@endcomponent
@endslot
@ -21,7 +37,11 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@if($snipeSettings::setupCompleted())
© {{ date('Y') }} {{ $snipeSettings->site_name }}. All rights reserved.
@else
© {{ date('Y') }} Snipe-it. All rights reserved.
@endif
@endcomponent
@endslot
@endcomponent

View file

@ -26,6 +26,12 @@ Route::group(['middleware' => 'auth'], function () {
/*
* Manufacturers
*/
Route::group([ 'prefix' => 'manufacturers', 'middleware' => ['auth'] ], function () {
Route::get('{manufacturers_id}/restore', [ 'as' => 'restore/manufacturer', 'uses' => 'ManufacturersController@restore']);
});
Route::resource('manufacturers', 'ManufacturersController', [
'parameters' => ['manufacturer' => 'manufacturers_id']
]);

View file

@ -28,64 +28,24 @@ clear
name="snipeit"
verbose="false"
hostname="$(hostname)"
fqdn="$(hostname --fqdn)"
hosts=/etc/hosts
spin[0]="-"
spin[1]="\\"
spin[2]="|"
spin[3]="/"
# Debian/Ubuntu friendly f(x)s
progress () {
echo -n " "
while kill -0 "$pid" > /dev/null 2>&1; do
for i in "${spin[@]}"; do
echo -ne "\b$i"
echo -ne "\\b$i"
sleep .1
done
done
echo ""
}
setvhdebian () {
find /etc/apache2/mods-enabled -maxdepth 1 -name 'rewrite.load' >/dev/null 2>&1
apachefile=/etc/apache2/sites-available/$name.conf
{
echo "<VirtualHost *:80>"
echo "ServerAdmin webmaster@localhost"
echo "<Directory $webdir/$name/public>"
echo " Require all granted"
echo " AllowOverride All"
echo " </Directory>"
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo " ErrorLog /var/log/apache2/snipeIT.error.log"
echo " CustomLog /var/log/apache2/access.log combined"
echo "</VirtualHost>"
} >> $apachefile
log "a2ensite $name.conf"
}
setvhcentos () {
apachefile=/etc/httpd/conf.d/$name.conf
{
echo "<VirtualHost *:80>"
echo "ServerAdmin webmaster@localhost"
echo " <Directory $webdir/$name/public>"
echo " Allow From All"
echo " AllowOverride All"
echo " Options +Indexes"
echo " </Directory>"
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo " ErrorLog /var/log/httpd/snipeIT.error.log"
echo " CustomLog /var/log/access.log combined"
echo "</VirtualHost>"
} >> "$apachefile"
}
log () {
if [ "$verbose" = true ]; then
eval "$@"
@ -94,20 +54,75 @@ log () {
fi
}
installpackages () {
case $distro in
ubuntu|debian)
for p in $PACKAGES; do
if dpkg -s "$p" >/dev/null 2>&1; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "DEBIAN_FRONTEND=noninteractive apt-get install -y $p"
fi
done;
;;
centos)
for p in $PACKAGES; do
if yum list installed "$p" >/dev/null 2>&1; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "yum -y install $p"
fi
done;
;;
fedora)
for p in $PACKAGES; do
if dnf list installed "$p" >/dev/null 2>&1; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "dnf -y install $p"
fi
done;
;;
esac
}
createvh () {
{
echo "<VirtualHost *:80>"
echo " <Directory $webdir/$name/public>"
echo " Allow From All"
echo " AllowOverride All"
echo " Options +Indexes"
echo " </Directory>"
echo ""
echo " DocumentRoot $webdir/$name/public"
echo " ServerName $fqdn"
echo "</VirtualHost>"
} >> "$apachefile"
}
installsnipeit () {
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';"
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $webdir/$name"
echo "* Configuring .env file."
cp "$webdir/$name/.env.example" "$webdir/$name/.env"
#TODO escape SED delimiter in variables
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 "s|^\\(APP_TIMEZONE=\\).*|\\1$tzone|" "$webdir/$name/.env"
sed -i "s|^\\(DB_HOST=\\).*|\\1localhost|" "$webdir/$name/.env"
sed -i "s|^\\(DB_DATABASE=\\).*|\\1snipeit|" "$webdir/$name/.env"
sed -i "s|^\\(DB_USERNAME=\\).*|\\1snipeit|" "$webdir/$name/.env"
sed -i "s|^\\(DB_PASSWORD=\\).*|\\1$mysqluserpw|" "$webdir/$name/.env"
sed -i "s|^\\(APP_URL=\\).*|\\1http://$fqdn|" "$webdir/$name/.env"
echo "* Installing and running composer."
cd "$webdir/$name/"
@ -131,22 +146,6 @@ installsnipeit () {
(crontab -l ; echo "* * * * * /usr/bin/php $webdir/$name/artisan schedule:run >> /dev/null 2>&1") | crontab -
}
isinstalled () {
if yum list installed "$@" >/dev/null 2>&1; then
true
else
false
fi
}
isdnfinstalled () {
if dnf list installed "$@" >/dev/null 2>&1; then
true
else
false
fi
}
openfirewalld () {
if [ "$(firewall-cmd --state)" == "running" ]; then
echo "* Configuring firewall to allow HTTP traffic only."
@ -155,6 +154,17 @@ openfirewalld () {
fi
}
configureselinux () {
#Check if SELinux is enforcing
if [ "$(getenforce)" == "Enforcing" ]; then
echo "* Configuring SELinux."
#Required for ldap integration
setsebool -P httpd_can_connect_ldap on
#Sets SELinux context type so that scripts running in the web server process are allowed read/write access
chcon -R -h -t httpd_sys_script_rw_t "$webdir/$name/"
fi
}
if [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then
distro="$(lsb_release -s -i)"
version="$(lsb_release -s -r)"
@ -165,7 +175,7 @@ elif [ -f /etc/os-release ]; then
#Order is important here. If /etc/os-release and /etc/centos-release exist, we're on centos 7.
#If only /etc/centos-release exist, we're on centos6(or earlier). Centos-release is less parsable,
#so lets assume that it's version 6 (Plus, who would be doing a new install of anything on centos5 at this point..)
#/etc/os-release also properly detects fedora
#/etc/os-release properly detects fedora
elif [ -f /etc/centos-release ]; then
distro="Centos"
version="6"
@ -187,11 +197,11 @@ echo " Welcome to Snipe-IT Inventory Installer for CentOS, Fedora, Debian and U
echo ""
shopt -s nocasematch
case $distro in
*Ubuntu*)
*ubuntu*)
echo " The installer has detected $distro version $version codename $codename."
distro=ubuntu
;;
*Debian*)
*debian*)
echo " The installer has detected $distro version $version codename $codename."
distro=debian
;;
@ -210,12 +220,8 @@ case $distro in
esac
shopt -u nocasematch
echo -n " Q. What is the FQDN of your server? ($fqdn): "
read -r fqdn
if [ -z "$fqdn" ]; then
fqdn="$(hostname --fqdn)"
fi
echo " Setting to $fqdn"
echo ""
read -rsn1 -p " Press any key to continue..."
echo ""
ans=default
@ -249,34 +255,25 @@ case $distro in
webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
apachefile=/etc/apache2/sites-available/$name.conf
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
progress
echo -n "* Upgrading packages with apt-get upgrade."
echo -n "* Updating installed packages."
log "apt-get update"
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 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
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="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"
installpackages
echo "* Configuring Apache."
createvh
log "a2enmod rewrite"
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
log "a2ensite $name.conf"
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."
@ -287,6 +284,7 @@ case $distro in
webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
apachefile=/etc/apache2/sites-available/$name.conf
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install -y software-properties-common"
@ -297,33 +295,23 @@ case $distro in
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."
echo -n "* Updating installed packages."
log "apt-get update"
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
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="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"
installpackages
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 "* Configuring Apache."
createvh
log "a2enmod rewrite"
log "a2ensite $name.conf"
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."
@ -340,33 +328,28 @@ case $distro in
webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
apachefile=/etc/apache2/sites-available/$name.conf
echo "* Adding MariaDB repository."
log "apt-get install software-properties-common"
log "apt-get install -y 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 -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
echo -n "* Updating installed packages."
log "apt-get update"
log "DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & 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 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
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="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"
installpackages
echo "* Configuring Apache."
createvh
log "phpenmod mcrypt"
log "phpenmod mbstring"
log "a2enmod rewrite"
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
log "a2ensite $name.conf"
echo "* Starting MariaDB."
log "service mysql start"
@ -374,10 +357,6 @@ case $distro in
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."
@ -388,35 +367,30 @@ case $distro in
webdir=/var/www
ownergroup=www-data:www-data
tzone=$(cat /etc/timezone)
apachefile=/etc/apache2/sites-available/$name.conf
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install software-properties-common"
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/ubuntu $codename main'"
#PHP7 repository
log "add-apt-repository ppa:ondrej/php -y"
echo -n "* Updating with apt-get update."
log "apt-get update" & pid=$!
echo -n "* Updating installed packages."
log "apt-get update"
log "DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & 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
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="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"
installpackages
echo "* Configuring Apache."
createvh
log "phpenmod mcrypt"
log "phpenmod mbstring"
log "a2enmod rewrite"
echo "* Creating the new virtual host in Apache."
setvhdebian
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
log "a2ensite $name.conf"
echo "* Starting MariaDB."
log "service mysql start"
@ -424,10 +398,6 @@ case $distro in
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."
@ -444,6 +414,7 @@ case $distro in
webdir=/var/www/html
ownergroup=apache:apache
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
apachefile=/etc/httpd/conf.d/$name.conf
echo "* Adding IUS, epel-release and MariaDB repositories."
mariadbRepo=/etc/yum.repos.d/MariaDB.repo
@ -462,16 +433,11 @@ case $distro in
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
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"
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 php71u-process"
installpackages
for p in $PACKAGES; do
if isinstalled "$p"; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "yum -y install $p"
fi
done;
echo "* Configuring Apache."
createvh
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "chkconfig mysql on"
@ -480,15 +446,7 @@ case $distro in
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';"
echo "* Creating the new virtual host in Apache."
setvhcentos
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
installsnipeit
if /sbin/service iptables status >/dev/null 2>&1; then
echo "* Configuring iptables."
@ -497,8 +455,6 @@ case $distro in
service iptables save
fi
installsnipeit
echo "* Setting Apache httpd to start on boot and starting service."
log "chkconfig httpd on"
log "/sbin/service httpd start"
@ -508,6 +464,7 @@ case $distro in
webdir=/var/www/html
ownergroup=apache:apache
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
apachefile=/etc/httpd/conf.d/$name.conf
echo "* Adding IUS, epel-release and MariaDB repositories."
log "yum -y install wget epel-release"
@ -515,16 +472,11 @@ case $distro in
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
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"
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 php71u-process"
installpackages
for p in $PACKAGES; do
if isinstalled "$p"; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "yum -y install $p"
fi
done;
echo "* Configuring Apache."
createvh
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "systemctl enable mariadb.service"
@ -533,31 +485,11 @@ case $distro in
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';"
#TODO make sure the apachefile doesnt exist isnt already in there
echo "* Creating the new virtual host in Apache."
setvhcentos
#TODO make sure this isnt already in there
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
installsnipeit
#open the firewall for HTTP traffic only
openfirewalld
#Check if SELinux is enforcing
if [ "$(getenforce)" == "Enforcing" ]; then
echo "* Configuring SELinux."
#Required for ldap integration
setsebool -P httpd_can_connect_ldap on
#Sets SELinux context type so that scripts running in the web server process are allowed read/write access
chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/
fi
configureselinux
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
@ -573,18 +505,14 @@ case $distro in
webdir=/var/www/html
ownergroup=apache:apache
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
apachefile=/etc/httpd/conf.d/$name.conf
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-cli php-common php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml"
installpackages
for p in $PACKAGES; do
if isdnfinstalled "$p"; then
echo " * $p already installed"
else
echo " * Installing $p ... "
log "dnf -y install $p"
fi
done;
echo "* Configuring Apache."
createvh
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "systemctl enable mariadb.service"
@ -593,31 +521,11 @@ case $distro in
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';"
#TODO make sure the apachefile doesnt exist isnt already in there
echo "* Creating the new virtual host in Apache."
setvhcentos
#TODO make sure this isnt already in there
echo "* Setting up hosts file."
echo >> $hosts "127.0.0.1 $hostname $fqdn"
installsnipeit
#open the firewall for HTTP traffic only
openfirewalld
#Check if SELinux is enforcing
if [ "$(getenforce)" == "Enforcing" ]; then
echo "* Configuring SELinux."
#Required for ldap integration
setsebool -P httpd_can_connect_ldap on
#Sets SELinux context type so that scripts running in the web server process are allowed read/write access
chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/
fi
configureselinux
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
@ -633,39 +541,40 @@ case $setupmail in
[yY] | [yY][Ee][Ss] )
echo -n " Outgoing mailserver address:"
read -r mailhost
sed -i 's,^\(MAIL_HOST=\).*,\1'$mailhost',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_HOST=\\).*|\\1$mailhost|" "$webdir/$name/.env"
echo -n " Server port number:"
read -r mailport
sed -i 's,^\(MAIL_PORT=\).*,\1'$mailport',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_PORT=\\).*|\\1$mailport|" "$webdir/$name/.env"
echo -n " Username:"
read -r mailusername
sed -i 's,^\(MAIL_USERNAME=\).*,\1'$mailusername',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_USERNAME=\\).*|\\1$mailusername|" "$webdir/$name/.env"
echo -n " Password:"
read -rs mailpassword
sed -i 's,^\(MAIL_PASSWORD=\).*,\1'$mailpassword',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_PASSWORD=\\).*|\\1$mailpassword|" "$webdir/$name/.env"
echo ""
echo -n " Encryption(null/TLS/SSL):"
read -r mailencryption
sed -i 's,^\(MAIL_ENCRYPTION=\).*,\1'$mailencryption',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_ENCRYPTION=\\).*|\\1$mailencryption|" "$webdir/$name/.env"
echo -n " From address:"
read -r mailfromaddr
sed -i 's,^\(MAIL_FROM_ADDR=\).*,\1'$mailfromaddr',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_FROM_ADDR=\\).*|\\1$mailfromaddr|" "$webdir/$name/.env"
echo -n " From name:"
read -r mailfromname
sed -i 's,^\(MAIL_FROM_NAME=\).*,\1'$mailfromname',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_FROM_NAME=\\).*|\\1$mailfromname|" "$webdir/$name/.env"
echo -n " Reply to address:"
read -r mailreplytoaddr
sed -i 's,^\(MAIL_REPLYTO_ADDR=\).*,\1'$mailreplytoaddr',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_REPLYTO_ADDR=\\).*|\\1$mailreplytoaddr|" "$webdir/$name/.env"
echo -n " Reply to name:"
read -r mailreplytoname
sed -i 's,^\(MAIL_REPLYTO_NAME=\).*,\1'$mailreplytoname',' "$webdir/$name/.env"
sed -i "s|^\\(MAIL_REPLYTO_NAME=\\).*|\\1$mailreplytoname|" "$webdir/$name/.env"
setupmail="yes"
;;
[nN] | [n|N][O|o] )