Difference between revisions of "Web App Packaging Notes"
From Amahi Wiki
Line 31: | Line 31: | ||
find . -name .htaccess -exec mv {} {}.tmp \; | find . -name .htaccess -exec mv {} {}.tmp \; | ||
=== Add Server (Service) Feature === | === Add Server (Service) Feature === | ||
− | * Install Script: | + | * Install Script (Fedora): |
cat > installscript.sh << 'EOF' | cat > installscript.sh << 'EOF' | ||
install -m 755 appname /etc/init.d/; | install -m 755 appname /etc/init.d/; | ||
Line 41: | Line 41: | ||
cd ..; | cd ..; | ||
rm -rf elevated; | rm -rf elevated; | ||
− | * Uninstall Script: | + | * Install Script (Ubuntu): |
+ | cat > installscript.sh << 'EOF' | ||
+ | install -m 755 appname /etc/init.d/; | ||
+ | update-rc.d appname defaults; | ||
+ | service appname start; | ||
+ | EOF | ||
+ | chmod 755 installscript.sh; | ||
+ | sudo ./installscript.sh; | ||
+ | cd ..; | ||
+ | rm -rf elevated; | ||
+ | * Uninstall Script (Fedora): | ||
mkdir elevated; | mkdir elevated; | ||
cd elevated; | cd elevated; | ||
Line 53: | Line 63: | ||
cd ..; | cd ..; | ||
rm -rf elevated; | rm -rf elevated; | ||
− | * | + | * Uninstall Script (Ubuntu): |
− | + | mkdir elevated; | |
+ | cd elevated; | ||
+ | cat > uninstallscript.sh << 'EOF' | ||
+ | service appname stop; | ||
+ | update-rc.d -f appname remove; | ||
+ | rm -f /etc/init.d/appname; | ||
+ | EOF | ||
+ | chmod 755 uninstallscript.sh; | ||
+ | sudo ./uninstallscript.sh; | ||
+ | cd ..; | ||
+ | rm -rf elevated; | ||
* Change service run level, start, and stop priority: | * Change service run level, start, and stop priority: | ||
Edit the service, i.e. ''/etc/init.d/adito'' and change the parameters (Run level: 0-6, start priority: 1-99, and stop priority: 1-99). | Edit the service, i.e. ''/etc/init.d/adito'' and change the parameters (Run level: 0-6, start priority: 1-99, and stop priority: 1-99). |
Revision as of 01:57, 29 May 2012
Contents
Database Restore
- Install Script:
# Check for backup of old version database if [ -f /var/hda/dbs/latest-appname.bz2 ]; then # Import old version database bzcat latest-app.bz2 |mysql -uapp -papp app else # Insert new version database mysql -uappname -pappname appname < appname.sql; fi
NOTE: if statement switches are:
-d: directory
-f: file
App Start on Boot
- Install Script:
/usr/bin/crontab -l > apache-crontab; cat >> apache-crontab << 'EOF' @reboot /var/hda/web-apps/appname/html/startup.sh EOF /usr/bin/crontab apache-crontab; rm -rf apache-crontab;
- Uninstall Script:
/usr/bin/crontab -l > apache-crontab; sed -i '/appname/d' apache-crontab; /usr/bin/crontab apache-crontab; rm -rf apache-crontab;
Find and Rename .htaccess Files:
find . -name .htaccess -exec mv {} {}.tmp \;
Add Server (Service) Feature
- Install Script (Fedora):
cat > installscript.sh << 'EOF' install -m 755 appname /etc/init.d/; /sbin/chkconfig appname on; /sbin/service appname start; EOF chmod 755 installscript.sh; sudo ./installscript.sh; cd ..; rm -rf elevated;
- Install Script (Ubuntu):
cat > installscript.sh << 'EOF' install -m 755 appname /etc/init.d/; update-rc.d appname defaults; service appname start; EOF chmod 755 installscript.sh; sudo ./installscript.sh; cd ..; rm -rf elevated;
- Uninstall Script (Fedora):
mkdir elevated; cd elevated; cat > uninstallscript.sh << 'EOF' /sbin/service appname stop; /sbin/chkconfig appname off; rm -f /etc/init.d/appname; EOF chmod 755 uninstallscript.sh; sudo ./uninstallscript.sh; cd ..; rm -rf elevated;
- Uninstall Script (Ubuntu):
mkdir elevated; cd elevated; cat > uninstallscript.sh << 'EOF' service appname stop; update-rc.d -f appname remove; rm -f /etc/init.d/appname; EOF chmod 755 uninstallscript.sh; sudo ./uninstallscript.sh; cd ..; rm -rf elevated;
- Change service run level, start, and stop priority:
Edit the service, i.e. /etc/init.d/adito and change the parameters (Run level: 0-6, start priority: 1-99, and stop priority: 1-99).
# chkconfig: 2345 56 26
Execute the following command as root user:
/sbin/chkconfig adito resetpriorities
Custom Webapp Options
Edit /etc/httpd/conf.d/####-appname.conf file (where #### is a 4 digit number). The web server will require restart to affect the changes.
- Change PHP Settings (add below ServerAlias):
<Files *.php> php_flag short_open_tag on php_flag magic_quotes_gpc Off php_flag magic_quotes_sybase Off php_flag magic_quotes_runtime Off php_flag register_globals Off php_flag session.auto_start Off php_flag suhosin.session.encrypt Off php_value upload_max_filesize 20M php_value post_max_size 100M php_value max_execution_time 300 php_value zend.enable_gc off </Files>
- Apache mod_rewrite to allow use of .htaccess (replace similar lines above </Directory>):
Options Indexes FollowSymLinks +ExecCGI AddHandler fcgid-script .fcg AllowOverride FileInfo Limit Options Indexes Order allow,deny Allow from all
- Redirect Webapp (add below ServerAlias):
ProxyPass / http://hda:10000/ ProxyPassReverse / http://hda:10000/
RedirectPermanent / http://hda:10000
Custom .htaccess File
- Use of .htaccess for Webmin (requires Apache mod-rewrite step above):
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://webmin.domain.com:10000/$1 [R,L]
Special Instructions
- Web Link Syntax:
<a href="http://www.google.com" target="_">Google</a>
- User Log in:
The administrator login is:<br /> <blockquote> <code> Name: admin<br /> Password: admin<br /> <br /> </code> </blockquote>
Scripted Functions
- Fully Qualified Domain Name:
HSTNM=`hostname -f` HST=`echo $HSTNM | awk -F'.' '{print $1}'` GRP=`echo $HSTNM | awk -F'.' '{print $2}'` DOM=`echo $HSTNM | awk -F'.' '{print $3}' | sed 's/\..*//'` if [$DOM == '']; then DOMNM='home.com' else DOMNM=$GRP'.'$DOM fi
- Arch (32- or 64-bit):
export MACHINE_TYPE=`uname -m`; if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit else # 32-bit fi
- HDA Domain Name:
export HDADOM=`cat /etc/resolv.conf | grep 'search' | awk '{ print $2 }'`;
- HDA IP Address:
export HDAIP=`ifconfig eth0 | grep "inet addr" | awk '{ print $2 }' | awk 'BEGIN { FS=":" } { print $2 }'`;
- First Admin User:
export FUSER=`/var/hda/platform/html/script/first-admin`
- Check OS Version:
export FVER=`cat /etc/fedora-release | awk -F'release ' '{print $2}' | sed 's/(Laughlin)//'`; if [ $FVER == '14' ]; then ... fi
Elevated Privileges (root)
- Scripts can be run from /var/hda/web-apps/*/elevated, /var/hda/apps/*/elevated or /var/hda/elevated directories.
mkdir -p elevated; cd elevated; cat > my-elevated-script << 'EOF' ...commands which need elevated privileges... EOF chmod +x my-elevated-script; sudo ./my-elevated-script; cd ..; rm -rf elevated;
Miscellaneous
- Patch Comment:
# FIXME - this needs to be hosted in dl.amahi.org prior to going live!
- AmahiSync Web Link:
http://username.amahi.me/Public/filename
- Patch Diff:
diff -r -N -b -u html.orig html > app-patch.diff
patch -s -p0 -E << 'EOF' .... contents of app-patch.diff here .... 'EOF'
patch -p0 -E < app-patch.diff
- Cat EOF:
with variables
cat > test << EOF ... text goes here ... EOF
and without variables
cat > test << 'EOF' ... text goes here ... 'EOF'
- Run as First Admin User:
su $FUSER -c command
- Netboot App Template