diff --git a/app/Console/Commands/ObjectImportCommand.php b/app/Console/Commands/ObjectImportCommand.php index fd2d91300e..e9964336b7 100644 --- a/app/Console/Commands/ObjectImportCommand.php +++ b/app/Console/Commands/ObjectImportCommand.php @@ -348,7 +348,7 @@ class ObjectImportCommand extends Command { $this->log('Company ' . $asset_company_name . ' was created'); return $company; } else { - $this->jsonError('Company', $company->getErrors()); + $this->log('Company', $company->getErrors()); } } else { $this->companies->add($company); @@ -470,7 +470,7 @@ class ObjectImportCommand extends Command { $this->log('Location ' . $asset_location . ' was created'); return $location; } else { - $this->jsonError('Location', $location->getErrors()) ; + $this->log('Location', $location->getErrors()) ; return $location; } } else { @@ -512,7 +512,7 @@ class ObjectImportCommand extends Command { $this->log('Supplier ' . $supplier_name . ' was created'); return $supplier; } else { - $this->jsonError('Supplier', $supplier->getErrors()); + $this->log('Supplier', $supplier->getErrors()); return $supplier; } } else { @@ -856,4 +856,4 @@ class ObjectImportCommand extends Command { -} \ No newline at end of file +} diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index f2f9aba4d0..f8749c407e 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -164,11 +164,11 @@ class Helper public static function managerList() { - $manager_list = array('' => '') + User::select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id')) - ->whereNull('deleted_at', 'and') - ->orderBy('last_name', 'asc') - ->orderBy('first_name', 'asc') - ->pluck('full_name', 'id')->toArray(); + $manager_list = User::where('deleted_at', '=', null) + ->orderBy('last_name', 'asc') + ->orderBy('first_name', 'asc')->get() + ->lists('full_name', 'id'); + return $manager_list; } @@ -187,13 +187,12 @@ class Helper public static function usersList() { - $users_list = array('' => trans('general.select_user')) + DB::table('users') - ->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id')) - ->whereNull('deleted_at') - ->where('show_in_list','=',1) - ->orderBy('last_name', 'asc') - ->orderBy('first_name', 'asc') - ->pluck('full_name', 'id'); + $users_list = User::where('deleted_at', '=', null) + ->where('show_in_list','=',1) + ->orderBy('last_name', 'asc') + ->orderBy('first_name', 'asc')->get() + ->lists('full_name', 'id'); + return $users_list; } diff --git a/app/Http/Controllers/AccessoriesController.php b/app/Http/Controllers/AccessoriesController.php index 5c29dc7642..736a0db964 100755 --- a/app/Http/Controllers/AccessoriesController.php +++ b/app/Http/Controllers/AccessoriesController.php @@ -313,6 +313,7 @@ class AccessoriesController extends Controller $logaction = new Actionlog(); $logaction->accessory_id = $accessory->id; + $logaction->asset_id = 0; $logaction->checkedout_to = $accessory->assigned_to; $logaction->asset_type = 'accessory'; $logaction->location_id = $user->location_id; diff --git a/app/Http/Controllers/AssetMaintenancesController.php b/app/Http/Controllers/AssetMaintenancesController.php index 3c2bb56a9d..a748f3d1d8 100644 --- a/app/Http/Controllers/AssetMaintenancesController.php +++ b/app/Http/Controllers/AssetMaintenancesController.php @@ -155,41 +155,14 @@ class AssetMaintenancesController extends Controller ] + AssetMaintenance::getImprovementOptions(); // Mark the selected asset, if it came in $selectedAsset = $assetId; - // Get the possible assets using a left join to get a list of assets and some other helpful info - $asset = Company::scopeCompanyables(DB::table('assets'), 'assets.company_id') - ->leftJoin('users', 'users.id', '=', 'assets.assigned_to') - ->leftJoin('models', 'assets.model_id', '=', 'models.id') - ->select( - 'assets.id', - 'assets.name', - 'first_name', - 'last_name', - 'asset_tag', - DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname') - ) - ->whereNull('assets.deleted_at') - ->get(); - $asset_array = json_decode(json_encode($asset), true); - $asset_element[ '' ] = 'Please select an asset'; - // Build a list out of the data results - for ($x = 0; $x < count($asset_array); $x++) { + $assets = Company::scopeCompanyables(Asset::all(), 'assets.company_id')->lists('detailed_name', 'id'); - if ($asset_array[ $x ][ 'full_name' ] != '') { - $full_name = ' (' . $asset_array[ $x ][ 'full_name' ] . ') ' . $asset_array[ $x ][ 'modelname' ]; - } else { - $full_name = ' (Unassigned) ' . $asset_array[ $x ][ 'modelname' ]; - } - $asset_element[ $asset_array[ $x ][ 'id' ] ] = - $asset_array[ $x ][ 'asset_tag' ] . ' - ' . $asset_array[ $x ][ 'name' ] . $full_name; - } - - // Get Supplier List $supplier_list = Helper::suppliersList(); // Render the view return View::make('asset_maintenances/edit') - ->with('asset_list', $asset_element) + ->with('asset_list', $assets) ->with('selectedAsset', $selectedAsset) ->with('supplier_list', $supplier_list) ->with('assetMaintenanceType', $assetMaintenanceType) @@ -321,40 +294,13 @@ class AssetMaintenancesController extends Controller '' => 'Select an improvement type', ] + AssetMaintenance::getImprovementOptions(); - // Get the possible assets using a left join to get a list of assets and some other helpful info - $asset = Company::scopeCompanyables(DB::table('assets'), 'assets.company_id') - ->leftJoin('users', 'users.id', '=', 'assets.assigned_to') - ->leftJoin('models', 'assets.model_id', '=', 'models.id') - ->select( - 'assets.id', - 'assets.name', - 'first_name', - 'last_name', - 'asset_tag', - DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname') - ) - ->whereNull('assets.deleted_at') - ->get(); - $asset_array = json_decode(json_encode($asset), true); - $asset_element[ '' ] = 'Please select an asset'; - - // Build a list out of the data results - for ($x = 0; $x < count($asset_array); $x++) { - - if ($asset_array[ $x ][ 'full_name' ] != '') { - $full_name = ' (' . $asset_array[ $x ][ 'full_name' ] . ') ' . $asset_array[ $x ][ 'modelname' ]; - } else { - $full_name = ' (Unassigned) ' . $asset_array[ $x ][ 'modelname' ]; - } - $asset_element[ $asset_array[ $x ][ 'id' ] ] = - $asset_array[ $x ][ 'asset_tag' ] . ' - ' . $asset_array[ $x ][ 'name' ] . $full_name; - } + $assets = Company::scopeCompanyables(Asset::all(), 'assets.company_id')->lists('detailed_name', 'id'); // Get Supplier List $supplier_list = Helper::suppliersList(); // Render the view return View::make('asset_maintenances/edit') - ->with('asset_list', $asset_element) + ->with('asset_list', $assets) ->with('selectedAsset', null) ->with('supplier_list', $supplier_list) ->with('assetMaintenanceType', $assetMaintenanceType) diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.php index a3a3899192..7a6f01c72d 100644 --- a/app/Http/Controllers/ConsumablesController.php +++ b/app/Http/Controllers/ConsumablesController.php @@ -319,6 +319,7 @@ class ConsumablesController extends Controller $logaction->consumable_id = $consumable->id; $logaction->checkedout_to = $consumable->assigned_to; $logaction->asset_type = 'consumable'; + $logaction->asset_id = 0; $logaction->location_id = $user->location_id; $logaction->user_id = Auth::user()->id; $logaction->note = e(Input::get('note')); diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index 5013317519..217ddac54e 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -156,6 +156,7 @@ class LicensesController extends Controller $insertedId = $license->id; // Save the license seat data + DB::transaction(function() use (&$insertedId,&$license) { for ($x=0; $x<$license->seats; $x++) { $license_seat = new LicenseSeat(); $license_seat->license_id = $insertedId; @@ -164,6 +165,7 @@ class LicensesController extends Controller $license_seat->notes = null; $license_seat->save(); } + }); // Redirect to the new license page @@ -435,40 +437,13 @@ class LicensesController extends Controller } // Get the dropdown of users and then pass it to the checkout view - $users_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))->whereNull('deleted_at')->orderBy('last_name', 'asc')->orderBy('first_name', 'asc')->lists('full_name', 'id'); + $users_list = Helper::usersList(); + $assets = Company::scopeCompanyables(Asset::all(), 'assets.company_id')->lists('detailed_name', 'id'); - // Left join to get a list of assets and some other helpful info - $asset = DB::table('assets') - ->leftJoin('users', 'users.id', '=', 'assets.assigned_to') - ->leftJoin('models', 'assets.model_id', '=', 'models.id') - ->select( - 'assets.id', - 'assets.name', - 'first_name', - 'last_name', - 'asset_tag', - DB::raw('concat(first_name," ",last_name) as full_name, assets.id as id, models.name as modelname') - ) - ->whereNull('assets.deleted_at') - ->get(); - - $asset_array = json_decode(json_encode($asset), true); - $asset_element[''] = 'Please select an asset'; - - // Build a list out of the data results - for ($x=0; $xwith('users_list', $users_list)->with('asset_list', $asset_element); + return View::make('licenses/checkout', compact('licenseseat')) + ->with('users_list', $users_list) + ->with('asset_list', $assets); } @@ -525,8 +500,8 @@ class LicensesController extends Controller // Redirect to the asset management page with error return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.asset_does_not_exist')); } - - if (($is_asset_id->assigned_to!=$assigned_to) && ($assigned_to!='')) { + $was_assigned_to = $is_asset_id->assigned_to; + if (($was_assigned_to!=$assigned_to) && !is_null($was_assigned_to) && ($was_assigned_to != '')) { //echo 'asset assigned to: '.$is_asset_id->assigned_to.'
license assigned to: '.$assigned_to; return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.owner_doesnt_match_asset')); } diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 9a7f4f3b37..6c8024a472 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -657,13 +657,7 @@ class UsersController extends Controller $location_list = Helper::locationsList(); $company_list = Helper::companyList(); - $manager_list = array('' => 'Select a User') + DB::table('users') - ->select(DB::raw('concat(last_name,", ",first_name," (",email,")") as full_name, id')) - ->whereNull('deleted_at') - ->where('id', '!=', $id) - ->orderBy('last_name', 'asc') - ->orderBy('first_name', 'asc') - ->lists('full_name', 'id'); + $manager_list = Helper::managerList(); // Show the page return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions')) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 4e66640c1b..3a48b9df6b 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -172,6 +172,14 @@ class Asset extends Depreciable } + public function getDetailedNameAttribute() { + if($this->assigned_user) { + $user_name = $user->fullName(); + } else { + $user_name = "Unassigned"; + } + return $this->asset_tag . ' - ' . $this->name . ' (' . $user_name . ') ' . $this->model->name; + } public function validationRules($id = '0') { return $this->rules; diff --git a/app/Models/User.php b/app/Models/User.php index 53bdcc6401..c24648b23b 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -118,6 +118,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return "{$this->first_name} {$this->last_name}"; } + public function getFullNameAttribute() + { + return $this->first_name . " " . $this->last_name; + } /** * Returns the user Gravatar image url. diff --git a/resources/views/hardware/import.blade.php b/resources/views/hardware/import.blade.php index 282b57955e..0ad8556c0d 100644 --- a/resources/views/hardware/import.blade.php +++ b/resources/views/hardware/import.blade.php @@ -73,24 +73,21 @@
Warning {{trans('admin/hardware/message.import.errorDetail')}}
- +
- - - + @foreach (session('import_errors') as $asset => $error) - @foreach ($error as $field => $values ) - - @foreach( $values as $fieldName=>$errorString) - - - @endforeach + @endforeach @endforeach diff --git a/snipeit.sh b/snipeit.sh index 9dd82167da..91572b666c 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -27,8 +27,9 @@ hostname="$(hostname)" fqdn="$(hostname --fqdn)" ans=default hosts=/etc/hosts -file=master.zip +file=v3.0-alpha2.zip #CHANGE THIS WHEN MASTER IS V3 AGAIN tmp=/tmp/$name +fileName=snipe-it-3.0-alpha2 rm -rf $tmp/ mkdir $tmp @@ -41,19 +42,22 @@ function isinstalled { fi } +if [ -f /etc/lsb-release ]; then + distro="$(lsb_release -s -i )" + version="$(lsb_release -s -r)" +elif [ -f /etc/os-release ]; then + distro="$(. /etc/os-release && echo $ID)" + version="$(. /etc/os-release && echo $VERSION_ID)" +#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..) +elif [ -f /etc/centos-release]; then + distro="Centos" + version="6" +else + distro="unsupported" +fi -# Lets find what distro we are using and what version -distro=$(. /etc/os-release && echo $ID) -version=$(. /etc/os-release && echo $VERSION_ID) -# if grep -q centos <<<$distro; then -# for f in $(find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null); -# do -# distro="${f:5:${#f}-13}" -# done; -# if [ "$distro" = "centos" ] || [ "$distro" = "redhat" ]; then -# distro+="$(rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release))" -# fi -# fi echo " _____ _ __________ @@ -71,15 +75,15 @@ echo "" shopt -s nocasematch case $distro in *Ubuntu*) - echo " The installer has detected Ubuntu as the OS." + echo " The installer has detected Ubuntu version $version as the OS." distro=ubuntu ;; *Debian*) - echo " The installer has detected Debian as the OS." + echo " The installer has detected Debian version $version as the OS." distro=debian ;; *centos*|*redhat*) - echo " The installer has detected $distro as the OS." + echo " The installer has detected $distro version $version as the OS." distro=centos ;; *) @@ -153,26 +157,21 @@ case $distro in echo "## Going to suppress more messages that you don't need to worry about. Please wait." sudo apt-get -y install apache2 >> /var/log/snipeit-install.log 2>&1 sudo apt-get install -y git unzip php5 php5-mcrypt php5-curl php5-mysql php5-gd php5-ldap libapache2-mod-php5 curl >> /var/log/snipeit-install.log 2>&1 - sudo service apache2 restart - - #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. - echo "## Setting up LAMP." - #sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ >> /var/log/snipeit-install.log 2>&1 # Get files and extract to web dir echo "" echo "## Downloading snipeit and extract to web directory." wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file >> /var/log/snipeit-install.log 2>&1 unzip -qo $tmp/$file -d $tmp/ - cp -R $tmp/snipe-it-master $webdir/$name + cp -R $tmp/$fileName $webdir/$name ## TODO make sure apache is set to start on boot and go ahead and start it #Enable mcrypt and rewrite echo "## Enabling mcrypt and rewrite" - sudo php5enmod mcrypt >> /var/log/snipeit-install.log 2>&1 + + sudo php5enmod mcrypt >> /var/log/snipeit-install.log 2>&1 sudo a2enmod rewrite >> /var/log/snipeit-install.log 2>&1 - sudo ls -al /etc/apache2/mods-enabled/rewrite.load >> /var/log/snipeit-install.log 2>&1 #Create a new virtual host for Apache. echo "## Create Virtual host for apache." @@ -190,63 +189,52 @@ case $distro in echo >> $apachefile " CustomLog /var/log/apache2/access.log combined" echo >> $apachefile "" + + echo "## Configuring .env file." + cat > $webdir/$name/.env <<-EOF + #Created By Snipe-it Installer + APP_TIMEZONE=$(cat /etc/timezone) + DB_HOST=localhost + DB_DATABASE=snipeit + DB_USERNAME=snipeit + DB_PASSWORD=$mysqluserpw + APP_URL=http://$fqdn + APP_KEY=$random32 + EOF + echo "## Setting up hosts file." echo >> $hosts "127.0.0.1 $hostname $fqdn" a2ensite $name.conf >> /var/log/snipeit-install.log 2>&1 #Modify the Snipe-It files necessary for a production environment. echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." - tzone=$(cat /etc/timezone); - sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php - - echo " Setting up bootstrap file." - sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php - - echo " Setting up database file." - cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - - echo " Setting up app file." - cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php - sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php - ## from mtucker6784: Is there a particular reason we want end users to have debug mode on with a fresh install? - #sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - - echo " Setting up mail file." - cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php - - ## TODO make sure mysql is set to start on boot and go ahead and start it - - #Change permissions on directories - echo "## Seting permissions on web directory." - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R www-data:www-data /var/www/ - # echo "## Finished permission changes." - - echo "## Input your MySQL/MariaDB root password: " - echo "" - sudo mysql -u root -p < $dbsetup - echo "" echo "## Securing Mysql" - echo "## I understand this is redundant. You don't need to change your root pw again if you don't want to." # Have user set own root password when securing install # and just set the snipeit database user at the beginning /usr/bin/mysql_secure_installation + ## TODO make sure mysql is set to start on boot and go ahead and start it + + echo "Creating Mysql Database and User." + echo "## Please Input your MySQL/MariaDB root password: " + echo "" + mysql -u root -p < $dbsetup + echo "" + #Install / configure composer echo "## Installing and configuring composer" - curl -sS https://getcomposer.org/installer | php - mv composer.phar /usr/local/bin/composer cd $webdir/$name/ - composer install --no-dev --prefer-source - php artisan app:install --env=production + curl -sS https://getcomposer.org/installer | php + php composer.phar install --no-dev --prefer-source + + #Change permissions on directories + echo "## Seting permissions on web directory." + sudo chmod -R 755 $webdir/$name/storage + sudo chmod -R 755 $webdir/$name/storage/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R www-data:www-data /var/www/ + # echo "## Finished permission changes." echo "## Restarting apache." service apache2 restart @@ -264,12 +252,11 @@ case $distro in apachefile=/etc/apache2/sites-available/$name.conf sudo apt-get update >> /var/log/snipeit-install.log 2>&1 sudo apt-get -y upgrade >> /var/log/snipeit-install.log 2>&1 - echo "## Installing packages." #We already established MySQL root & user PWs, so we dont need to be prompted. Let's go ahead and install Apache, PHP and MySQL. echo "## Setting up LAMP." - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ >> /var/log/snipeit-install.log 2>&1 + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lamp-server^ >> /var/log/snipeit-install.log 2>&1 if [ "$version" == "16.04" ]; then sudo apt-get install -y git unzip php php-mcrypt php-curl php-mysql php-gd php-ldap php-mbstring >> /var/log/snipeit-install.log 2>&1 @@ -284,13 +271,13 @@ case $distro in echo "## Enabling mcrypt and rewrite" sudo php5enmod mcrypt >> /var/log/snipeit-install.log 2>&1 sudo a2enmod rewrite >> /var/log/snipeit-install.log 2>&1 - # Get files and extract to web dir fi + # Get files and extract to web dir echo "" echo "## Downloading snipeit and extract to web directory." wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file >> /var/log/snipeit-install.log 2>&1 unzip -qo $tmp/$file -d $tmp/ - cp -R $tmp/snipe-it-master $webdir/$name + cp -R $tmp/$fileName $webdir/$name ## TODO make sure apache is set to start on boot and go ahead and start it @@ -316,65 +303,52 @@ case $distro in echo "## Setting up hosts file." echo >> $hosts "127.0.0.1 $hostname $fqdn" + a2ensite $name.conf >> /var/log/snipeit-install.log 2>&1 - #Modify the Snipe-It files necessary for a production environment. - echo "## Modify the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." - tzone=$(cat /etc/timezone); - sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php - - echo " Setting up bootstrap file." - sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php - - echo " Setting up database file." - cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - - echo " Setting up app file." - cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php - sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php - ## from mtucker6784: Is there a particular reason we want end users to have debug mode on with a fresh install? - #sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - - echo " Setting up mail file." - cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + cat > $webdir/$name/.env <<-EOF + #Created By Snipe-it Installer + APP_TIMEZONE=$(cat /etc/timezone) + DB_HOST=localhost + DB_DATABASE=snipeit + DB_USERNAME=snipeit + DB_PASSWORD=$mysqluserpw + APP_URL=http://$fqdn + APP_KEY=$random32 + EOF ## TODO make sure mysql is set to start on boot and go ahead and start it - #Change permissions on directories - echo "## Seting permissions on web directory." - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R www-data:www-data /var/www/ - # echo "## Finished permission changes." - - echo "## Input your MySQL/MariaDB root password: " - sudo mysql -u root -p < $dbsetup + # Setup Mysql, then run the command. + /usr/bin/mysql_secure_installation + echo "## Creating MySQL Database and user. " + echo "## Please Input your MySQL/MariaDB root password: " + mysql -u root -p < $dbsetup echo "## Securing Mysql" # Have user set own root password when securing install # and just set the snipeit database user at the beginning - /usr/bin/mysql_secure_installation #Install / configure composer echo "## Installing and configuring composer" - curl -sS https://getcomposer.org/installer | php - mv composer.phar /usr/local/bin/composer cd $webdir/$name/ - composer install --no-dev --prefer-source - php artisan app:install --env=production + curl -sS https://getcomposer.org/installer | php + php composer.phar install --no-dev --prefer-source + + #Change permissions on directories + echo "## Seting permissions on web directory." + sudo chmod -R 755 $webdir/$name/storage + sudo chmod -R 755 $webdir/$name/storage/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R www-data:www-data /var/www/$name + # echo "## Finished permission changes." echo "## Restarting apache." service apache2 restart ;; centos ) - if [ "$version" == "6" ]; + if [ "$version" == "6" ]; then ##################################### Install for Centos/Redhat 6 ############################################## webdir=/var/www/html @@ -417,19 +391,20 @@ case $distro in wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file >> /var/log/snipeit-install.log 2>&1 unzip -qo $tmp/$file -d $tmp/ - cp -R $tmp/snipe-it-master $webdir/$name + cp -R $tmp/$fileName $webdir/$name # Make mariaDB start on boot and restart the daemon echo "## Starting the mariaDB server."; chkconfig mysql on /sbin/service mysql start - echo "## Input your MySQL/MariaDB root password: " - mysql -u root < $dbsetup - echo "## Securing mariaDB server."; /usr/bin/mysql_secure_installation + echo "## Creating MySQL Database/User." + echo "## Please Input your MySQL/MariaDB root password: " + mysql -u root -p < $dbsetup + ##TODO make sure the apachefile doesnt exhist isnt already in there #Create the new virtual host in Apache and enable rewrite echo "## Creating the new virtual host in Apache."; @@ -437,7 +412,6 @@ case $distro in echo >> $apachefile "" echo >> $apachefile "" - echo >> $apachefile "LoadModule rewrite_module modules/mod_rewrite.so" echo >> $apachefile "" echo >> $apachefile "" echo >> $apachefile "ServerAdmin webmaster@localhost" @@ -461,36 +435,20 @@ case $distro in chkconfig httpd on /sbin/service httpd start - #Modify the Snipe-It files necessary for a production environment. - echo "## Modifying the Snipe-It files necessary for a production environment." - echo " Setting up Timezone." tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g'); - sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php + echo "## Configuring .env file." - echo " Setting up bootstrap file." - sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php + cat > $webdir/$name/.env <<-EOF + #Created By Snipe-it Installer + APP_TIMEZONE=$tzone + DB_HOST=localhost + DB_DATABASE=snipeit + DB_USERNAME=snipeit + DB_PASSWORD=$mysqluserpw + APP_URL=http://$fqdn + APP_KEY=$random32 + EOF - echo " Setting up database file." - cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - - echo " Setting up app file." - cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php - sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php - ## from mtucker6784: Is there a particular reason we want end users to have debug mode on with a fresh install? - #sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - - echo " Setting up mail file." - cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php - - # Change permissions on directories - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R apache:apache $webdir/$name #Install / configure composer echo "## Configure composer" @@ -498,8 +456,10 @@ case $distro in curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source - echo "## Installing Snipe-IT" - php artisan app:install --env=production + # Change permissions on directories + sudo chmod -R 755 $webdir/$name/storage + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name #TODO detect if SELinux and firewall are enabled to decide what to do #Add SELinux and firewall exception/rules. Youll have to allow 443 if you want ssl connectivity. @@ -508,7 +468,6 @@ case $distro in # firewall-cmd --reload service httpd restart - ;; elif [ "$version" == "7" ]; then ##################################### Install for Centos/Redhat 7 ############################################## @@ -541,21 +500,21 @@ case $distro in wget -P $tmp/ https://github.com/snipe/snipe-it/archive/$file >> /var/log/snipeit-install.log 2>&1 unzip -qo $tmp/$file -d $tmp/ - cp -R $tmp/snipe-it-master $webdir/$name + cp -R $tmp/$fileName $webdir/$name # Make mariaDB start on boot and restart the daemon echo "## Starting the mariaDB server."; systemctl enable mariadb.service systemctl start mariadb.service - echo "## Input your MySQL/MariaDB root password " - mysql -u root -p < $dbsetup - echo "## Securing mariaDB server."; echo ""; echo ""; /usr/bin/mysql_secure_installation + echo "## Creating MySQL Database/User." + echo "## Please Input your MySQL/MariaDB root password " + mysql -u root -p < $dbsetup ##TODO make sure the apachefile doesnt exhist isnt already in there #Create the new virtual host in Apache and enable rewrite @@ -589,43 +548,37 @@ case $distro in systemctl enable httpd.service systemctl restart httpd.service - #Modify the Snipe-It files necessary for a production environment. - echo "## Modifying the Snipe-IT files necessary for a production environment." - echo " Setting up Timezone." + tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}'); - sed -i "s,UTC,$tzone,g" $webdir/$name/app/config/app.php + echo "## Configuring .env file." - echo " Setting up bootstrap file." - sed -i "s,www.yourserver.com,$hostname,g" $webdir/$name/bootstrap/start.php + cat > $webdir/$name/.env <<-EOF + #Created By Snipe-it Installer + APP_TIMEZONE=$tzone + DB_HOST=localhost + DB_DATABASE=snipeit + DB_USERNAME=snipeit + DB_PASSWORD=$mysqluserpw + APP_URL=http://$fqdn + APP_KEY=$random32 - echo " Setting up database file." - cp $webdir/$name/app/config/production/database.example.php $webdir/$name/app/config/production/database.php - sed -i "s,snipeit_laravel,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,travis,snipeit,g" $webdir/$name/app/config/production/database.php - sed -i "s,password' => '',password' => '$mysqluserpw',g" $webdir/$name/app/config/production/database.php - - echo " Setting up app file." - cp $webdir/$name/app/config/production/app.example.php $webdir/$name/app/config/production/app.php - sed -i "s,production.yourserver.com,$fqdn,g" $webdir/$name/app/config/production/app.php - sed -i "s,Change_this_key_or_snipe_will_get_ya,$random32,g" $webdir/$name/app/config/production/app.php - sed -i "s,false,true,g" $webdir/$name/app/config/production/app.php - - echo " Setting up mail file." - cp $webdir/$name/app/config/production/mail.example.php $webdir/$name/app/config/production/mail.php + EOF # Change permissions on directories - sudo chmod -R 755 $webdir/$name/app/storage - sudo chmod -R 755 $webdir/$name/app/private_uploads - sudo chmod -R 755 $webdir/$name/public/uploads - sudo chown -R apache:apache $webdir/$name + #Install / configure composer cd $webdir/$name curl -sS https://getcomposer.org/installer | php php composer.phar install --no-dev --prefer-source - php artisan app:install --env=production + sudo chmod -R 755 $webdir/$name/storage + sudo chmod -R 755 $webdir/$name/storage/private_uploads + sudo chmod -R 755 $webdir/$name/public/uploads + sudo chown -R apache:apache $webdir/$name + # Make SeLinux happy + sudo chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ #TODO detect if SELinux and firewall are enabled to decide what to do #Add SELinux and firewall exception/rules. Youll have to allow 443 if you want ssl connectivity. # chcon -R -h -t httpd_sys_script_rw_t $webdir/$name/ @@ -633,8 +586,7 @@ case $distro in # firewall-cmd --reload systemctl restart httpd.service - ;; - + else echo "Unable to Handle Centos Version #. Version Found: " $version return 1 @@ -642,7 +594,7 @@ case $distro in esac echo "" -echo " ***If you want mail capabilities, open $webdir/$name/app/config/production/mail.php and fill out the attributes***" +echo " ***If you want mail capabilities, edit $webdir/$name/.env and edit based on .env.example***" echo "" echo " ***Open http://$fqdn to login to Snipe-IT.***" echo ""
AssetFieldParameterErrorsErrors
{{ $asset }} {{ $field }} {{$fieldName}}{{$errorString[0]}} {{ $field }}: + @foreach( $values as $errorString) + {{$errorString[0]}} + @endforeach +