InDefero

Sign in or create your account | Project List | Help

Issue 211: Install script to simplify the installation process

Reported by Sindre Myren, Apr 30, 2009

Some ideas/suggestions around how a installation script might be 
writen:

- Write in python (as python is already a dependency).
have the scrip 'module based', i.e.:

indefero/install.py # nice interactive CLI, runs the others
indefero/install.d/GitPlugin.py # interactive CLI
indefero/install.d/SvnPlugin.py # interactive CLI
indefero/install.d/MercurialPlugin.py # interactive CLI

Have some predefined files aviable:
indefero/files/httpd-indero.conf # apache config file:
indefero/files/redhat/git-daemon-ini-d (aviable on web)
indefero/files/archlinux/git-daemon-init-d (I have already written 
one of those)
indefero/files/debian/git-daemon-runsv (written one)
indefero/files/ubuntu/git-daemon-runsv (in docs)

Simplify the config files.
Possible split it up into:
cinf/idf.php (just read all the other files and return cfg)
conf/main.php_dist # Git home dir, fqdns and so on, git_svn_dir
conf/db.php_dist # settings one do not want to share with anyone
conf/email.php_dist
conf/advanced.php_dist # more advanced controll, eg git repos dir 
and so on

I might be able to help you, if I can find the time, but I can't 
promise anything :-(

Comment 1 by Sindre Myren, May 1, 2009

Maybe use curses bindings.

Documented here:
http://docs.python.org/library/curses.html
http://docs.python.org/howto/curses.html

Include a small python curses 'mocup' script to show the consept. 
(Testet with Python 2.5.4)

Comment 2 by Loïc d'Anterroches, May 1, 2009

Labels: Priority:High, Type:Enhancement, -Priority:Medium, -Type:Defect

Comment 3 by Loïc d'Anterroches, May 7, 2009

See 
http://groups.google.com/group/indefero-users/ 
browse_thread/thread/c9a60f05d31f33c9 
it looks we are going to have a nice installer!

Comment 4 by Dustin Krysak, May 7, 2009

As requested (by Loïc), I am adding my bash script here.

As I mentioned on the mailing list, I had written this for myself, 
so it is not the prettiest (but not the worst) coding. I have run it 
on about 4 VM's thus far. I also just changed the indefero base file 
name (IE indefero-0.8.3) to a var to that as new versions come out, 
the script itself does not need to be updated. I have not tested it 
after that change, but going to do so now.

Just keep in mind, I threw this together for personal use, so it can 
use some polishing.

I am obviously very interested in any changes so I can make sure I 
am using them too.

Comment 5 by Dustin Krysak, May 7, 2009

One additional note, This was written for CentOS 5.X (tested on 
5.3). And does use 3rd party repositories to get the needed software 
(EPEL, and CentOS Testing). they were needed to get newer versions 
of php, etc that were requirements for Pluf and so on. By default 
the 3rd party repos are NOT enabled, so you must use the 
--enablerepo switch with yum (as the script does). I imagine down 
the road, the installer over all will need to be not so specific to 
a platform. I am just most familiar with this one, and since written 
for myself originally.... =-)

Comment 6 by Dustin Krysak, May 7, 2009

New version with a bug fixed. The part where I had the gmail config 
commented out didn't have the $ escaped properly. It never caused me 
any issues in the tests because the section is commented out by 
default.

Comment 7 by Loïc d'Anterroches, May 7, 2009

Thanks a lot! I will dig into it. Do not worry for the coding style 
and the CentOS specific stuff, this will already be a great help to 
get a generic install script up and running. 

Once again thanks a lot!
Summary: Install script to simplify the installation process

Comment 8 by Dustin Krysak, May 10, 2009

Anyone else have a go with this installer?

Just curious....

Comment 9 by Sindre Myren, May 10, 2009

Hi. I want to inform you that I am working on a curses/prompt 
command line interface where you might  interactivly choose what 
part of the installation you want to preform. (much like the cli 
debian installer).

I have been using python for this. It is suppost to use curses if 
libcurses are installed, but fall back to prompt if it is not.

I have only been making the gui part, so I don't think it duplicates 
the work of Dustin.

I have a lot of exams comming up shortly, so I don't think I have 
time to finsish it up:-(

When the UI is working, I will publish a link to my indefero clone, 
in case anyone else would like to pull it.

Comment 10 by Sindre Myren, May 13, 2009

Allright. The UI is now usable if you would like to pull it.

PS! At the moment the UI does nothing! It is only a front-end, from 
which you might add functionality to the different choices.

A fork is aviable at:
git://insomnia.ed.ntnu.no/indefero.git
just pull the 'install' branch.

here is the webpage:
https://insomnia.ed.ntnu.no/code/index.php/p/indefero/source/tree/ins
tall/

PS! added some things to the .gitignore file, like:
*.pyc
*.swp

The curses part is a bit buggy, so I use standard prompt for the 
default UI.

Use "python setup.py -c" or "python setup.py 
--curses" to try the curses variant of the script.

PS! Dustin. I looked at your script. I will probably have to install 
InDefero on CentOS this summer. Your script will defiantly make this 
easier=) Although I think I will edit it a bit before using it=)

I think partitioning it up into smaller pieces and tie it together 
with my UI, would make a good/easy and general installation script.

Please feel free to ask if you have any questions/requests.

My time is a bit limited at the moment, but I shall try to answer.

Comment 11 by Sindre Myren, May 14, 2009

Rebased git://insomnia.ed.ntnu.no/indefero.git on 9:45pm Thursday 
(GMT), to clean up commit messages.

Comment 12 by Sindre Myren, May 21, 2009

Curses issue fixed, UI libs now fully operational. Next step:
make the first installation scripts, and tie them to the UI.

Planned approach:
Have settings.py take care of main program loop.

Have scripts it indefero/install looking something like this:

InstallerScriptExample.py:
# (C) ...
# END LICENCE BLOCK
#
from os import system

from install.lib.actiontypes import type_action, type_submenu

## Functions ##
def action_do_a(os, settings):
    """ do a:
    @param os  String - Chosen os in main menu
    @param setings  Dict with settings from the settings.ini file
    @return  Message string
    """
    if "cent os" in OS.lower():
        exit_code = system("...")
    elif "ubuntu" in OS.lower():
        exit_code = system("...")
    if exit_code:
        return "Operation A failed"
    return "Operation A was Successful"


def action_do_b():
    # Do something else.. A sub_menu perhaps..
    # Return string of some kind.

# Menu lists:
MENU = [
    "[0] Do A",
    "[1] Do B",
]

ACTIONS = [
    (type_action, action_do_a),
    (type_submenu, action_do_b),
]

Please feel free to come with any suggestions.

Comment 13 by Sindre Myren, Jun 6, 2009

So here is what i ended up with...
The diff is against Commit d014b36ee28eef1f3e87e3c7bfcfc68486ee8498

It is a python installer for InDefero with a fancy curses UI in 
front of it. Unlike Dustins script, it requires you to download 
indefero first, and it does not take care of the hole installation 
process, but extensions for the script may be written.

Changes made to InDefero:
- src/IDF/conf/idf.php partially replaced with an easier to read and 
modify settings.ini file.
- www/index.php modified not to comment out line 29

Features:
- Easy configuration file
- Auto replace text in index.php
- Edit configuration files, (auto copy filename-dist to filename).
- Preform a 'basic' installation:
  * Symlink or copy index.php and media folder.
  * Install Apache configuration file (files/site-indefero) for 
indefero and svn)
- Nice Curses UI
- Fallback prompt UI, when curses UI is to buggy.
- Tested for Python 2.4->3.0
- Stagedir (Use to test copying of files, file permissions and so 
on, or to format a .deb or pacman .tar.gz for  example)
- "Easily" add new scripts/sub-menus to the installer in 
the menu and scripts folder.
- Make scripts and menu options do different operations 
for different OS-es/linux distroes.
- Run certain operations as root, and the rest as normal user.


Only the basic installation is handled at the moement, but adding 
additional scripts and menus should be rather easy

It's not perfect though..

Known Bugs:
With python 2.6 and 3.0, the host terminal is 'messed up' when you 
use the editor functionallety, or do system calls. Workaround: Use 
prompt mode with install.py -p

There is a lot more code then with Dustin's approach, and after 
writhing this thing, I sometimes think that having a simple 
bash-script installer (with some more interaction with the user then 
Dustin's script), would be a faster, cleaner, and easier and way to 
do this then the path I chose.

Comment 14 by Dustin Krysak, Jun 6, 2009

If a person wanted to be prompted, adding prompts to the original 
script would have been trivial.  =-)

But I would say that so long as a person can get it installed, that 
is all that matters!

My Indefero install is working nice and smooth still, so I myself 
may not try the installer for some time.

Comment 15 by Sindre Myren, Jun 14, 2009

You are of course right Dustin. So i have trashed all my previous 
stuff (to much code, to complicated), and started from scratch:
https://insomnia.ed.ntnu.no/code/index.php/p/indefero/

Basically it's a copy of your script, but with prompts, and using 
python.

The basic syntax is like this:

    # Symlink www files amd create attachement folder:
    print_header("Creating symlinks and folders")
    cmds = ("cd %s" % wwwdir,
            "ln -s %s/www/index.php" % IDFDIR,
            "ln -s %s/www/media" % IDFDIR,
            "mkdir -p %s" % attdir,
            "chown %s.%s %s" % (webuser, webgroup, 
attdir),
            )
    ask_system("Create symlinks and folders?",cmds)
    del cmds

first I print a header, then I creates a list of commands, and asks 
the user if he wants to execute them.

I haven't actually finished it, but if anyone would care to hack on 
it I have added FIXME labels for what I think needs to be done.

If the script itself is of no direct interest, these files might be:
/src/idf_installer/files (follow the above link)

I still have this one change to InDefero, that I have created a 
settings.ini configuration file:
settings.ini-dist

Mainly I have created it to be able to read from the same file in 
bout python and php, but also as i remembered idf.php to be far to 
complicated for normal users, and contain far to many configurations.

Comment 16 by Lorenzo Vogelsang, Nov 19, 2009

OK, I'm new with indefero. And, it would appear that I'm late to 
this thread. Oh well.

I am currently using Flyspray (flyspray.org) and DokuWiki 
(dokuwiki.org) together as issue tracker and wiki.

The installer for Flyspray goes something like this:

-- Copy your files to a directory under or into docroot.
-- Create your database.
-- From your browser run http://example.com/setup/index.php

The index.php is a stand alone PHP application that presents dialogs 
on the relevant directory locations, database names, login 
credentials, .... When setup is finished it tells you to delete the 
setup directory from your webhost. ... At that point, the install is 
done.

Is this something to consider? Is this interesting?

Comment 17 by Jakub Vitak, Apr 29, 2010

Sindre's source is dead :-/

adopted and updated! 
http://code.koudynet.eu/p/indefero/source/tree/installer/

get by: git clone git://code.koudynet.eu/indefero.git

I think it needs review, but I haven't time yet .. but soon or later 
I will do it

Comment 18 by Sindre Myren, Apr 29, 2010

Yes it's dead. Firstly it wasn't at a stage where it was actually 
working. Secondly, I didn't feel it was any good. I can get it back 
up if anybody is interested too look at it (or better still, attach 
it).

I think it's a good idea, if anybody are going to keep working on an 
installer, that you somehow simplified the php config files.

Usually the user wouldn't like to configure more then, databse, mail 
+ root folders/urls for indefero svn and git.

It would be nice if all such basic configurations was seperated from 
the main configuration file.

Good luck on your installer Jakub!

Comment 19 by Jakub Vitak, May 1, 2010

I know installing _is not_ pretty part of using InDefero - 
unfortunately - because still lot of people ask in mailing list how 
to setup it.

I don't promise anything but I think this could help lot of people 
(which want to use own instance).

Anyway I want to code accessible for everyone to even get a chance 
for feedback than deny it before anybody could test it.

Last thing - anything that's somehow working is good ;-)

Created: 1 year 4 months ago by Sindre Myren

Updated: 4 months 1 day ago

Status: New

Followed by: 6 persons

Labels:
Priority:High
Type:Enhancement