Application Install Scripts
The install and uninstall scripts are executed in the webapp directory for the app, say, for application
foobar
The script is run in
/var/hda/web-apps/foobar
Useful Things
The install script can use some utility scripts (we expect to improve on these as time goes on, so please feel free to ask for things to be canned as scripts as you see the need!). See below for
Running Perl/Pyton/Ruby/Other scripts
By default, scripts are run in bash.
However, if you start your script by
#!
Then they will be executed with whatever you provide there, e.g.:
#!/usr/bin/perl #!/usr/bin/python #!/usr/bin/ruby
Running the scripts by hand
You can run the script by hand to test. This can simplify the debugging a lot.
mkdir -p /tmp/my-webapp-test cd /tmp/my-webapp-test wget http://url-for-muy-tar-ball-or-zip-file.tgz untar/unzip mytarball mv main-dir html then run the script here ...
hda-install-file utility script
This utility script will install files with some details of the local installation replaced, namely:
@HDA_NETWORK@ --> 192.168.1 (the network) @HDA_SELF@ --> 10 (the ip address of the HDA) @HDA_DOMAIN@ --> home.com (the domain) @HDA_NETMASK@ --> 255.255.255 (the netmask) @HDA_NICKNAME@ --> <nick> (the nickname of the dyndns - <nick>.yourhda.com)
please don't assume much and use as generally as possible, as these may support more general settings in the future (like a more general netmask, etc.)
to change the contents of a file while installing an webapp
i.e. you would need this to edit configuration files for one-click installs in HDA.
for the examples i will use the (actually in development) configuration-file of the piwik-web-app.
example source (empty example-config-file delivered by piwik package):
[file.orig]
- <?php exit; ?> DO NOT REMOVE THIS LINE
- this file is just here for documentation purpose
- the config.ini.php is normally created during the installation process
- when this file is absent it triggers the Installation process
- the config.ini.php file contains information about the super user and the database access
[superuser] login = yourSuLogin password = yourSuPassword email = hello@piwik.org
[database] host = localhost username = databaseLogin password = datatabasePassword dbname = databaseName adapter = PDO_MYSQL ; PDO_MYSQL or MYSQLI tables_prefix = piwik_
example goal (in the config file after this process):
[changed.orig]
- <?php exit; ?> DO NOT REMOVE THIS LINE
- file automatically generated during the piwik installation process (and updated later by some other plugins)
[superuser] login = admin password = 34131c9eef54abfe3aaed6fa275d01dd email = admin@hda.@HDA_DOMAIN@
[database] host = localhost username = root password = "hda" dbname = piwik adapter = PDO_MYSQL port = 3306
tables_prefix = piwik_
What we have to do to achive this is to write a script. ;) We need to get the differences between the files. For this we will use diff-command. you got the files orig.file and changed.file. Now we need to diff them! use the shell for this and type (inside that folder) diff -U orig.file changed.file > my.diff
After you've done this, you got a file named my.diff. Inside it you got the code which you need to add inside your inside script. :)
hda-create-db-and-user utility script
Utility Script for creating a MySQL database and user for accessing the newly created database.
Usage: hda-create-db-and-user [options] dbname
-u, --user=name Specifies the user name to use. Default: dbname@localhost -d, --drop Drops the user and the DB. Default: dbname@localhost
-h, --help Show this help message.
By default: the database, the user and the user's password are all the same. The user is always username@localhost.
Example: To create a database named foo hda-create-db-and-user foo
To drop the same database hda-create-db-and-user -d foo
Have fun creating your apps. If you need something ask at IRC :)