-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
V9 enhance script readability #1
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
Conversation
- Replaced ECHO sequence with a CAT command. On branch v9_enhance_script_readability Changes to be committed: modified: V9/odoo_install.sh
|
NOTE: not (yet) tested! |
|
but it should work normally :) |
|
@tvibliani Thanks a lot for cleaning up this code and making it a lot more readable! I will give it a test run this afternoon. If everything works fine I will merge it 👍 |
- In order to automate installation, added -y option to "apt-get
install" command, as without -y the command enters interactive
mode with a question below:
"Do you want to continue? [Y/n]"
|
I tried it on Debian Jessie, as sudo is not installed on debian by default, first I've got: # ./odoo_install.sh
---- Update Server ----
./odoo_install.sh: line 43: sudo: command not foundthen installed sudo with: |
|
I still have problem (not related to the changes in this PR) with wkhtmltopdf as it's dependency libjpeg-turbo8 can't be found on Debian Jessie... the command used in the script "dpkg -i" installs the package regardless of dependency availability. so this installation script were completed successfully, but wkhtmlpdf is broken because of missing dependency and cause internal server error of odoo instance on Debian Jessie. it's better way to install the deb package with "gdebi" command, but I don't know if it's available by default on Ubuntu or not, so I do not know if it'll be safe to replace "dpkg -i " with "gdebi " |
|
I should just adapt wkhtmltopdf download link to my distribution :) as per the download table at official download page |
|
@tvibliani I did one run on an Ubuntu 14.04 and everything worked fine with your cleaned up code so far. I should fix that too. |
- Added gdebi-core package to install tools list in order to have available the 'gdebi' command.
- Automatically choose between wkhtml2pdf x64 and x32 versions, according of host architecture. - Replaced "dpkg -i" with "gdebi --n", in order to have installed all wkhtml2pdf dependencies automatically, if any of them is missing from the system. - Make shortcuts in /usr/bin directory, instead of copying actual binary files that are part of installed wkthml2pdf package. - Added .gitignore in order to prevent garbage file upload to the repository.
|
I'd like to throw out all the sudo stuff from the script. We can put one check at the beginning of the script, like: # Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fithen user will have to run the script as root, and no more need to have prefixed all the commands with sudo. then for example, installer script itself may be run with one line command(on Ubuntu): By doing so:
What you think about? |
|
the pasword request possibly were come from "su", but there is no need for su, we can remove it as well |
|
the fragment: echo -e "\n---- Create custom module directory ----"
sudo su $OE_USER -c "mkdir $OE_HOME/custom"
sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons"will become: echo -e "\n---- Create custom module directory ----"
mkdir -p $OE_HOME/custom/addons
chown $OE_USER:$OE_USER $OE_HOME/custom/addonsthat's it, no sudo, no su and no interactive mode in the middle of installation. |
|
@tvibliani I'm not very experience with pull requests and Github so forgive me for not pulling this in. As for removing all sudo parts and only allowing root installations with this code: I understand what you want to do and the idea is nice but it has a major downside. A lot of users that have access to the system have no root acces but enough rights to execute scripts like this. When we'd limit this script to root you would need the root credentials and acces to execute this script, which is in my opinion more of a downside than a plus side. Don't you think? |
|
I've NOT removed any sudo yet, and I'm not going to. at least in this PR. I wanted to discuss such a possiblility first. But script is already limited to sudoers, such a change will not add necessity for root credentials, as any sudoer can run the script after. Now we have to run |
|
@tvibliani I know! I just decided to split this script up until it is done. When it is fully done & fully working I'll pull them over to the 9.0 script! 👍 |
- Integer overflow test does not worked properly and is not reliable indicator of host architecture, it replaced with "getconf LONG_BIT" that was tested and worked properly on Ubuntu 14.04. now wkhtml2pdf downloads are correctly adapted to x64 and x32 hosts.
|
Note to self: This line still requests a password. Because of the sudo chown. |
|
Note, if we remove sudo from inside, then it'll require sudo outside of script, so it'll be You're right, there is too much changes for one PR, but I was not going to do so much at the beginning... first I've done only readability cleanup, but later I added new feature, that adapts download link of wkhtml2pdf to host architecture x64 or x32, because as I tried to install odoo9 with the original script on Ubuntu x32 machine, I've got error because of incompatible wkhtml2pdf (the This package is uninstallable
Wrong architecture 'amd64'now it's fixed. I tested it on Ubuntu 14.4 - x32, and now download link were adapted correctly and installation were successful. |
|
@tvibliani I understand. I have lots of ideas to continue this script though! Edit: The latest script version seems to work perfect on Ubuntu 14.04. |
|
I think that's already managed to be that way. if you start/stop/restart an odoo instance using init script (the |
|
I tested it on Debian Jessie, just with wkhtml2pdf download likns adapted, using following: recommended wkhtml2pdf version according Odoo v8 Documentation is 0.12.1, but that version is not installable on Jessie, so I used 0.12.2 and above links are corresponding to this version. So far it woks fine (I printed some documents from Odoo). A latest version is tested on Ubuntu 14.4 - x32 as well. As I noted before, I'd like to remove sudo stuff and also there is a few things I do not like in the original script, for example odoo system user should NOT be in sudoers group and should NOT be created with --shell=/bin/bash, there is always more to do as we move forward. I think further changes should be considered as a separate task and I'll join you later for that in the separated development folder that you created, but I'm done with this PR I think. At this point installation script is working as expected. Please review and merge the PR. Thanks, |
|
fixes #3 |
|
I've advanced the installation script a bit, I wanted to propose that changes through new PR, but as I tried to do so, it showed up to me old changes from this PR. because of that it could not be a clean PR... so I'm waiting this pr to be merged and I'll make new PR after. meanwhile you can check latest version in "development" branch at my fork. I'm agree with you about having development version separately, but separated folder is not an elegant way to do so. I've finally used separated branch at my fork, called "development" instead of separate folder. It should be nice if you create as well separated branch for development, if you still want to have separate development version (also note that other hand, script is small enough to edit it directly in place), so we'll be able to push some WIP to that branch, without altering baseline code in your master branch. Of course it's possible to do an other way around, to have development in master and create "production" branch for tested/finalised code, but separate development/production versions is better through branches than through directories I think. |
|
@tvibliani, I decided to clean up my whole repo structure since this was clearly not working well. Could you create a new pull request against my current version 9.0 please? We'll continue from there on? 👍 |
|
Nice. I'll make 2 pull requests then, the part of changes that are present in this PR, are tested by both of us and it can be go directly to the 9.0 branch I think, but later changes that I've made at my side are not yet well tested, I'll create separated PR from that changes to master. so it'll two separated PR, one to 9.0 (tested code), another to master(later code). is that OK? |
Changes to be committed: renamed: V9/odoo_install.sh -> odoo_install.sh
|
PR is moved. Please refer to #4 |
|
@tvibliani Thats perfect, thanks! I'll try to test and review the master version ASAP! |
|
Thank you for merge the PR. 👍 |
|
@tvibliani No problem! I've just did a testrun for the V9.0 script and it seems to work fine. It doesn't ask for any password anymore and everything runs fine out of the box. So the script seems to perfectly fine. 😄 |
|
👍 |
the echo command sequence used to constitute an init script replaced with more appropriate cat command, which makes this part of installer script much more human readable...