Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer fine tuning #2993

Merged
merged 13 commits into from
Jan 11, 2017
Merged

Installer fine tuning #2993

merged 13 commits into from
Jan 11, 2017

Conversation

morph027
Copy link

  • used shellcheck to lint the script
  • added MariaDB repo to Ubuntu
  • added logging function log() to get rid of duplicate code (adding results to logfile)

Tested on Debian / Ubuntu using Docker

@snipe
Copy link
Owner

snipe commented Nov 30, 2016

Can you let me kmow when you think this is ready for review and merging? I don't want to merge and then have a bunch of follow up merges

@morph027 morph027 changed the title Installer fine tuning [WIP] Installer fine tuning Nov 30, 2016
@morph027
Copy link
Author

Sure, I'll let you know! Updated the title for now...

By the way, thanks for this awesome project!

@morph027 morph027 changed the title [WIP] Installer fine tuning Installer fine tuning Dec 1, 2016
@morph027
Copy link
Author

morph027 commented Dec 1, 2016

Ok, testing done, think it's ready to get reviewed...

[EDIT]: Sorry, just found another hidden issue ;)

@snipe
Copy link
Owner

snipe commented Dec 6, 2016

@uberbrady can I get a sanity check on this before merge?

@therealjoshuad
Copy link

is suido a typo on line 19?

@morph027
Copy link
Author

morph027 commented Dec 6, 2016

Ah, sure...weird. Looks like vim insert typo ;) And fixed...

Copy link
Collaborator

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a ton of things much clearer to me, and I think overall it's a good change. I've left in a lot of questions - please see if you can explain some of those things and we'll get this merged in in no time.

@@ -16,13 +16,12 @@

# ensure running as root
if [ "$(id -u)" != "0" ]; then
exec sudo "$0" "$@"
exec suido "$0" "$@"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, or is this something I don't know about?

@@ -36,16 +35,16 @@ spin[1]="\\"
spin[2]="|"
spin[3]="/"

rm -rf $tmp/
rm -rf ${tmp:?}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean:

if tmp is defined
  `rm -rf tmp` 
else 
  `rm -rf ?`
end

If so, that rm -rf ? will delete any single-character files and recursively delete any single-letter directories. If we're trying to do something to handle when there is no tmp I think I'd prefer something like a straight if statement, or at least rm -rf ${tmp:tmp_directory_is_not_defined_so_this_will_generate_an_error}. I honestly think the if version is the simplest and most importantly, the clearest.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, this prevents deleting / if $tmp is unset.

https://github.com/koalaman/shellcheck/wiki/SC2115

The colon is bash builtin fallback for unset variables.

@@ -56,24 +55,26 @@ progress () {
}

vhenvfile () {
sudo ls -al /etc/apache2/mods-enabled/rewrite.load >> /var/log/snipeit-install.log 2>&1
find /etc/apache2/mods-enabled -maxdepth 1 -name 'rewrite.load' >/dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, it just piques my curiousity - why do this? Is it something about showing up in the logs a little bit clenaer? Well, actually, I guess it won't show up in the logs at all, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo " ErrorLog /var/log/apache2/snipeIT.error.log"
echo " CustomLog /var/log/apache2/access.log combined"
echo "</VirtualHost>"
} >> $apachefile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much cleaner! I like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo >> $hosts "127.0.0.1 $hostname $fqdn"
a2ensite $name.conf >> /var/log/snipeit-install.log 2>&1
a2ensite $name.conf >/dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one that no longer logs - any particular reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, might be better to log this too...

@@ -542,6 +556,6 @@ echo ""
echo "* Cleaning up..."
rm -f snipeit.sh
rm -f install.sh
rm -rf $tmp/
rm -rf ${tmp:?}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That same bit about :? that I mentioned before - sure this is alright?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

rpm -Uvh $tmp/ius-release*.rpm >> /var/log/snipeit-install.log 2>&1
yum -y install wget epel-release >/dev/null 2>&1
wget -P $tmp/ https://centos7.iuscommunity.org/ius-release.rpm >/dev/null 2>&1
rpm -Uvh $tmp/ius-release*.rpm >/dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more logging in here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

echo -n " ##" $p "Installing... "
yum -y install $p >> /var/log/snipeit-install.log 2>&1
echo -n " ## installing $p ... "
yum -y install "$p" >/dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No logs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

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/$fileName $webdir/$name
wget -P "$tmp/" "https://github.com/snipe/snipe-it/archive/$file" >/dev/null 2>&1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No log here?

sudo chmod -R 755 $webdir/$name/storage/private_uploads
sudo chmod -R 755 $webdir/$name/public/uploads
sudo chown -R apache:apache $webdir/$name
perms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, there's that "perms" thing again. What's that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above ;)

@snipe snipe merged commit 734e87f into snipe:master Jan 11, 2017
n8felton added a commit to n8felton/snipe-it that referenced this pull request May 12, 2017
snipe pushed a commit that referenced this pull request May 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants