mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge branch 'develop' of github.com:snipe/snipe-it into develop
This commit is contained in:
commit
c3cd329604
|
@ -231,7 +231,7 @@ class AssetsController extends Controller
|
|||
$directory= public_path('uploads/assets/');
|
||||
// Check if the uploads directory exists. If not, try to create it.
|
||||
if (!file_exists($directory)) {
|
||||
mkdir($directory, 0755);
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
$path = public_path('uploads/assets/'.$file_name);
|
||||
try {
|
||||
|
@ -288,7 +288,7 @@ class AssetsController extends Controller
|
|||
*/
|
||||
public function getEdit($assetId = null)
|
||||
{
|
||||
|
||||
|
||||
// Check if the asset exists
|
||||
if (!$asset = Asset::find($assetId)) {
|
||||
// Redirect to the asset management page
|
||||
|
@ -407,7 +407,7 @@ class AssetsController extends Controller
|
|||
$directory= public_path('uploads/assets/');
|
||||
// Check if the uploads directory exists. If not, try to create it.
|
||||
if (!file_exists($directory)) {
|
||||
mkdir($directory, 0755);
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
|
||||
$file_name = str_random(25).".".$extension;
|
||||
|
@ -840,7 +840,7 @@ class AssetsController extends Controller
|
|||
|
||||
// Check if the uploads directory exists. If not, try to create it.
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path, 0755);
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
if ($handle = opendir($path)) {
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ class AssetsController extends Controller
|
|||
|
||||
return View::make('hardware/labels')->with('assets', $assets)->with('settings', $settings)->with('count', $count)->with('settings', $settings);
|
||||
|
||||
|
||||
|
||||
|
||||
} elseif (Input::get('bulk_actions')=='delete') {
|
||||
|
||||
|
@ -1854,12 +1854,12 @@ class AssetsController extends Controller
|
|||
$users_list = Helper::usersList();
|
||||
// Filter out assets that are not deployable.
|
||||
$assets = Asset::RTD()->get();
|
||||
|
||||
|
||||
$assets_list = Company::scopeCompanyables($assets, 'assets.company_id')->lists('detailed_name', 'id')->toArray();
|
||||
|
||||
|
||||
return View::make('hardware/bulk-checkout')->with('users_list', $users_list)->with('assets_list', $assets_list);
|
||||
}
|
||||
|
||||
|
||||
public function postBulkCheckout(Request $request)
|
||||
{
|
||||
|
||||
|
@ -1869,31 +1869,31 @@ class AssetsController extends Controller
|
|||
|
||||
$user = User::find(e(Input::get('assigned_to')));
|
||||
$admin = Auth::user();
|
||||
|
||||
|
||||
$asset_ids = array_filter(Input::get('selected_assets'));
|
||||
|
||||
|
||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||
$checkout_at = e(Input::get('checkout_at'));
|
||||
} else {
|
||||
$checkout_at = date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
|
||||
if (Input::has('expected_checkin')) {
|
||||
$expected_checkin = e(Input::get('expected_checkin'));
|
||||
} else {
|
||||
$expected_checkin = '';
|
||||
}
|
||||
|
||||
|
||||
$has_errors = false;
|
||||
$errors = [];
|
||||
DB::transaction(function() use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids)
|
||||
{
|
||||
{
|
||||
foreach($asset_ids as $asset_id)
|
||||
{
|
||||
$asset = Asset::find($asset_id);
|
||||
|
||||
|
||||
$error = $asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
||||
|
||||
|
||||
if($error)
|
||||
{
|
||||
$has_errors = true;
|
||||
|
@ -1901,12 +1901,12 @@ class AssetsController extends Controller
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!$errors) {
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
|
||||
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/bulk-checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors);
|
||||
}
|
||||
|
|
62
snipeit.sh
62
snipeit.sh
|
@ -31,9 +31,31 @@ file=master.zip
|
|||
tmp=/tmp/$name
|
||||
fileName=snipe-it-master
|
||||
|
||||
spin[0]="-"
|
||||
spin[1]="\\"
|
||||
spin[2]="|"
|
||||
spin[3]="/"
|
||||
|
||||
rm -rf $tmp/
|
||||
mkdir $tmp
|
||||
|
||||
# Debian/Ubuntu friendly f(x)
|
||||
progress () {
|
||||
while kill -0 $pid > /dev/null 2>&1
|
||||
do
|
||||
for i in "${spin[@]}"
|
||||
do
|
||||
if [ -e /proc/$pid ]; then
|
||||
echo -ne "\b$i"
|
||||
sleep .1
|
||||
else
|
||||
echo -ne "\n\n"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function isinstalled {
|
||||
if yum list installed "$@" >/dev/null 2>&1; then
|
||||
true
|
||||
|
@ -116,9 +138,9 @@ case $setpw in
|
|||
echo -n " Q. What do you want your snipeit user password to be?"
|
||||
read -s mysqluserpw
|
||||
echo ""
|
||||
ans="no"
|
||||
ans="no"
|
||||
;;
|
||||
*) echo " Invalid answer. Please type y or n"
|
||||
*) echo " Invalid answer. Please type y or n"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
@ -149,14 +171,17 @@ case $distro in
|
|||
echo "## Updating Debian packages in the background. Please be patient."
|
||||
echo ""
|
||||
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
|
||||
|
||||
sudo apt-get update >> /var/log/snipeit-install.log & pid=$! 2>&1
|
||||
progress
|
||||
sudo apt-get -y upgrade >> /var/log/snipeit-install.log & pid=$! 2>&1
|
||||
progress
|
||||
echo "## Installing packages."
|
||||
sudo apt-get -y install mariadb-server mariadb-client
|
||||
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 apt-get -y install apache2 >> /var/log/snipeit-install.log & pid=$! 2>&1
|
||||
progress
|
||||
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 & pid=$! 2>&1
|
||||
progress
|
||||
|
||||
# Get files and extract to web dir
|
||||
echo ""
|
||||
|
@ -209,14 +234,13 @@ case $distro in
|
|||
|
||||
#Modify the Snipe-It files necessary for a production environment.
|
||||
echo "## Modify the Snipe-It files necessary for a production environment."
|
||||
|
||||
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
|
||||
|
||||
## 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 ""
|
||||
|
@ -250,16 +274,22 @@ case $distro in
|
|||
echo ""
|
||||
echo "## Updating ubuntu in the background. Please be patient."
|
||||
echo ""
|
||||
echo -n "Updating with apt-get update... ${spin[0]}"
|
||||
sudo apt-get update >> /var/log/snipeit-install.log & pid=$! 2>&1
|
||||
progress
|
||||
echo -n "Upgrading packages with apt-get upgrade... ${spin[0]}"
|
||||
sudo apt-get -y upgrade >> /var/log/snipeit-install.log & pid=$! 2>&1
|
||||
progress
|
||||
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 & pid=$! 2>&1
|
||||
echo ""
|
||||
progress
|
||||
if [ "$version" == "16.04" ]; then
|
||||
sudo apt-get install -y git unzip php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml >> /var/log/snipeit-install.log 2>&1
|
||||
sudo apt-get install -y git unzip php php-mcrypt php-curl php-mysql php-gd php-ldap php-xml php-zip php-mbstring >> /var/log/snipeit-install.log 2>&1
|
||||
#Enable mcrypt and rewrite
|
||||
echo "## Enabling mcrypt and rewrite"
|
||||
|
@ -282,8 +312,6 @@ case $distro in
|
|||
|
||||
## TODO make sure apache is set to start on boot and go ahead and start it
|
||||
|
||||
|
||||
|
||||
sudo ls -al /etc/apache2/mods-enabled/rewrite.load >> /var/log/snipeit-install.log 2>&1
|
||||
|
||||
#Create a new virtual host for Apache.
|
||||
|
@ -305,7 +333,7 @@ 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
|
||||
a2ensite $name.conf >> /var/log/snipeit-install.log
|
||||
|
||||
cat > $webdir/$name/.env <<-EOF
|
||||
#Created By Snipe-it Installer
|
||||
|
@ -320,7 +348,7 @@ case $distro in
|
|||
EOF
|
||||
|
||||
## TODO make sure mysql is set to start on boot and go ahead and start it
|
||||
|
||||
echo "## MySQL Phase next."
|
||||
# Setup Mysql, then run the command.
|
||||
/usr/bin/mysql_secure_installation
|
||||
echo "## Creating MySQL Database and user. "
|
||||
|
|
Loading…
Reference in a new issue