Changes

From Amahi Wiki
Jump to: navigation, search
mkdir -p /tmp/my-webapp-test
cd /tmp/my-webapp-test
wget <nowiki>http://url-for-muy-tar-ball-or-zip-file.tgz</nowiki>
untar/unzip mytarball
mv main-dir html
then run the script here ...
**NOTE: many apps include a .htaccess file that is hidden and may cause you problems. try to remove this if needed!
== Use of inline files with EOF ==
Here is a quick guide to make install scripts easier with [[Patch and diff]]
== The hda-install-file utility script ==
This utility script will install files with some details of the local installation replaced, namely:
(like a more general netmask, etc.)
== The amahi-download utility script ==
This script is useful to more securely download files in install scripts. It's used with a URL and the sha1sum of the file it's meant to download:  amahi-download -h Usage: /usr/bin/amahi-download [options] <filename|url> <sha1sum> -h, --help Show this help message. This script will exit with a failure if the download fails or the checksum signature fails to check. == to 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.
== hda-create-db-and-user utility script ==
Utility Script for creating a MySQL MariaDB database and user for accessing the newly created database.
<small>
To drop the same database '''<small>hda-create-db-and-user -d foo</small>'''
= Make an app start when server (re)boots =
 
The best way to have your app start when the computer boots/reboots is to add an entry to the crontab. Since the install scripts are run by the user 'apache', you can only add entries to apache's crontab. This means you cannot start any apps that require root privileges.
 
Here is an example:
 
First use the techniques from above to create the crontab entry that starts your app/daemon/server. the line starting with @reboot is the crontab entry. at the end of the crontab entry put a comment that is unique to your app. It will be used to remove the crontab item later during uninstall.
<small>
cat > run_web-app.cron << EOF
@reboot $PWD/html/web-app.py -d # web-app
EOF
</small>
 
This made a file called web-app.cron in your apps folder. web-app.py is the program that will run as the system starts.
 
Next; the first line lists all the items in the current crontab, and copys it to a temp file. the second line add's our crontab enty to the bottom of the file. the third line loads the contents of the temp file back into the users crontab.
 
<small>
crontab -l | grep -v "no crontab for" > /tmp/crontab.txt # copy the current crontab to a tempfile
cat run_web-app.cron >> /tmp/crontab.txt #add our apps line to the tempfile
crontab /tmp/crontab.txt #make the tempfile the crontab
</small>
'''NOTE'''
The script's that manipulate the crontab needs to be carefully crafted. If not coded correctly, the users crontab will be overwritten!
 
Make sure that if you add an entry to the crontab that you have the uninstall script remove it.
Here the first line list's all enties in the crontab and grep removes any line with the string "web-app" in it. this is why it is important to use a unique identifyer at the end of your crontab line. The remaining items from the crontab go into a tempfile then the contents of the tempfile are loaded into the users crontab again.
<small>
crontab -l | grep -v web-app > /tmp/web-app-uninstall-crontab.txt
crontab /tmp/web-app-uninstall-crontab.txt
</small>
Have fun creating your apps. If you need something ask at in the [http://webchat.freenode.net/?channels=amahi IRC ] :)
12,424

edits