Changes

From Amahi Wiki
Jump to: navigation, search
no edit summary
Updated: 07 Jul 2021
=== Database Restore ===
* Install Script:
fi
::'''NOTE:''' if statement switches are:<blockquote> ' ''-d''': = directory<br /> 'or ''-f'''= file :or  zcat app.sql.gz |mysql -u$HDA_DB_USERNAME -p$HDA_DB_PASSWORD $HDA_DB_DBNAME : or  filemysql -u$HDA_DB_USERNAME -p$HDA_DB_PASSWORD $HDA_DB_DBNAME </blockquote>app.sql;
=== Database Update to UTF8 ===
<pre style="white-space: pre-wrap; word-break: keep-all;">echo "alter database appdb charset=utf8" | mysql -uappdb u$HDA_DB_USERNAME -pappdbp$HDA_DB_PASSWORD</pre> === Large Database Load ===For restoring large SQL files, include the following lines at the beginning of the file. This will disable key checks that are not necessary when restoring a database dump, speeding up load time: SET @@session.unique_checks = 0; SET @@session.foreign_key_checks = 0; or <pre style="white-space: pre-wrap; word-break: keep-all;">mysql --max_allowed_packet=128M -u$HDA_DB_USERNAME -p$HDA_DB_PASSWORD $HDA_DB_DBNAME < app.sql;</pre> === Backup App Config on Uninstall === echo Backing up config to sharename share; cp -r ../filename /var/hda/files/sharename/filename-$(date +%Y%m%d%H%M%S); chown apache:users /var/hda/files/sharename/filename*;
=== App Start on Boot ===
find . -name .htaccess -exec mv {} {}.tmp \;
=== Add Server (Service) Feature Functions ===* Install, Enable, and StartFedora: install -m 755 appname /etc/init.d/; /sbin/chkconfig appname on; /sbin/Check if service appname start;Ubuntuis active: install systemctl is-m 755 appname /etc/init.d/; update-rc.d appname defaults; active service appname start;* Uninstall, Enable/Disable, and StopFedora: /sbinstart/stop service appname stop;: /sbin/chkconfig appname off; rm systemctl enable --f /etc/init.d/appname;Ubuntu: now service appname stop; updatesystemctl disable -rc.d -f appname remove; rm -f /etc/init.d/appname;now service* Enable and Start (Fedora)Reload system daemon
echo Reloading systemctl daemon;
systemctl daemon-reload;
echo Enabling appname * Start/Stop/Restart app service; systemctl enable appname.service;
echo Starting appname service;
systemctl start appname.service;
* Disable and Stop (Fedora)
echo Stopping appname service;
systemctl stop appname.service;
echo Disabling Restarting appname service; systemctl disable restart appname.service;* Restart Service if 'active' echo Reloading if [ `systemctl daemonis-active appname.service` == "active" ];then echo Restarting appname.service... systemctl daemon-reload;restart appname.service echo Done! fi
* 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
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''):
<blockquote>:<u>Fedora 19-25 (PHP5)</u><pre><Files *.php> values or flags</Files></pre>:<u>Fedora 27 or greater (PHP7)</u><pre><IfModule mod_php7.c>values or flags</IfModule></pre>:Values and Flags for use with above:<pre>php_value memory_limit 256Mphp_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 output_buffering Offphp_value upload_max_filesize 20M php_value post_max_size 100M php_value max_execution_time 300 php_value zend.enable_gc off php_value default_charset "UTF-8" php_value iconv.input_encoding "UTF-8" php_value iconv.internal_encoding "UTF-8" php_value iconv.output_encoding "UTF-8" php_value mbstring.internal_encoding UTF-8 php_value mbstring.http_output UTF-8 php_value mbstring.encoding_translation On php_value mbstring.func_overload 6</pre> </Filesblockquote>* Displays PHP Modules Installed php -m* Apache mod_rewrite to allow use of .htaccess for Fedora 19 /21/23/25/27 (replace similar lines above ''</Directory>''):
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AddHandler fcgid-script .fcg
AllowOveride FileInfo Limit Options Indexes
'''AllowOverride All'''
Order allow,deny
Allow from all
===Special Instructions===
* Web Link Syntax:
<a href="<nowiki>http://www.google.com</nowiki>" target="_">Google</a>
* User Log in:
<pre>The administrator login is:<br />
</code>
</blockquote></pre>
* Reference to wiki:
<pre style="white-space: pre-wrap; word-break: keep-all;"><nowiki><b>NOTE:</b> Refer to the <a href="https://wiki.amahi.org/index.php/appname" target="_">appname</a> Amahi wiki page for help in changing the default configuration settings.</nowiki></pre>
===Scripted Functions===
* [[Script_variables|Script Variables]]: environment variables built into the Amahi 7 or greater platform
* Check if file exists:
<nowiki>[[ -f /etc/passwd ]]</nowiki> && echo "File exist" || echo "File does not exist"
* Check if directory exists:
[ -d /var/log ] && echo "Directory exist" || echo "Directory does not exist"
* Compare files:
<pre style="white-space: pre-wrap; word-break: keep-all;">[[ /etc/resolv.conf -ef /etc/resolv.conf ]] && echo "Same files" || echo "Different Files"
[[ /etc/resolv.conf -ef /etc/passwd ]]</nowiki> && echo "Same files" || echo "Different Files"</pre>
* Source file unarchives into ''unpack'' folder:
# Check for unpack folder
if [ -d unpack ]; then
rm -rf html;
mv unpack html;
fi
* Create/Preserve Share
if [ -d /var/hda/files/sharename/ ]; then
echo sharename share exists...files preserved!
else
mkdir -p /var/hda/files/sharename
chown -R $HDA_1ST_ADMIN:users /var/hda/files/sharename
chmod -R 775 /var/hda/files/sharename
echo sharename share created...permissions set!
fi
* Remove Share
echo sharename share files preserved!
echo
echo To remove them, in terminal run:
echo ‘sudo rm -rf /var/hda/files/sharename’
* Network Interface Name:
HDA_DEVICE=`nmcli d | grep 'ethernet' | awk '{print $1;}'`;
or
HDA_DEVICE=`ip route | awk '/^default/ { printf $5 }'`;
or
<pre style="white-space: pre-wrap; word-break: keep-all;">HDA_DEVICE=`ip addr show |grep -w inet |egrep -v '(127.0.0.1|tun|secondary)' |awk '{ print $7}'`</pre>
* Fully Qualified Domain Name:
HSTNM=`hostname -f`
* HDA Domain Name:
HDADOM=`cat /etc/resolv.conf | grep 'search' | awk '{ print $2 }'`;
:or<pre style="white-space: pre-wrap; word-break: keep-all;">HDADOM=$(echo "SELECT value FROM settings WHERE name='domain'" | mysql hda_production -uamahihda -pAmahiHDARulez -s)</pre>
* HDA IP Address
<pre style="white-space: pre-wrap; word-break: keep-all;">HDAIP=$(/sbin/ip -o -4 addr list $HDA_DEVICE | awk '{print $4}' | cut -d/ -f1);</pre>* HDA Broadcast IP<pre style="white-space: pre-wrap; word-break: keep-all;">HDA_BIP=`ip addr show |grep -w inet |egrep -v '(127.0.0.1|tun)' |awk '{ print $4}'`</pre>* HDA MAC Address HDA_MAC=`ip addr show | grep -w ether | awk '{ print $2 }'`* HDA Netmask<pre style="white-space: pre-wrap; word-break: keep-all;">HDA_NET=`ip addr show |grep -w inet |egrep -v '(127.0.0.1|tun)' |awk '{ print $2}'| cut -d "/" -f 2`</pre>* HDA Subnet<pre style="white-space: pre-wrap; word-break: keep-all;">HDA_SUB=`netstat -r |egrep -v '(Kernel|Destination|default|10|docker0)' |awk '{ print $1}'`</pre>
* First Admin User:
FUSER=`/var/hda/platform/html/script/first-admin`
:or<pre style="white-space: pre-wrap; word-break: keep-all;">FUSER=$(echo "SELECT login FROM users WHERE admin=1 ORDER BY id ASC LIMIT 1" | mysql hda_production -uamahihda -pAmahiHDARulez -s)* Arch (32- or 64-bit): ARCH=`getconf LONG_BIT` if [ "$ARCH" = "64" ]; then # 64-bit else # 32-bit fi</pre>
* Check OS Version:
<pre style="white-space: pre-wrap; word-break: keep-all;">FVER=`cat /etc/fedora-release | awk -F'release ' '{print $2}' | sed 's/(Laughlin)//'`;</pre>
if [ $FVER == '14' ]; then
...
fi
:or<pre style="white-space: pre-wrap; word-break: keep-all;"> FVER=`cat /etc/fedora-release | awk -F'release ' '{print $2}' | sed 's/(Verne)//'`;
if [ $FVER == '16' ]; then
...
fi</pre>* Install Ubuntu (DEB) or Fedora (RPM) package
if [ -f /etc/fedora-release ]; then
yum localinstall -y package.rpm --nogpgcheck
fi
 
if [ -f /etc/lsb-release ]; then
dpkg -i package.deb
fi
rm -rf elevated;
===MiscellaneousSED One-Liners===* Suppress Console OutputUpdate application domain: command &sed -i 's|<nowiki> http:/dev/nullapp</nowiki>|<nowiki>http://app</nowiki>.'"$HDA_DOMAIN"'|' app.sql;* Remove blank lines from file:
sed -i '/^$/d' filename
* Delete lines in file:
sed '/pattern/d' file
* Add lines before pattern:
<pre>sed -i '/pattern/i \
line1 \
line2' file</pre>
* Add lines after pattern:
<pre>sed -i '/pattern/a \
line1 \
line2​' file</pre>
* Insert line based on text1 (Previous Line):
sed -i '/text1/ i\text2' /filename;
* Insert text at line number 3:
sed '2 aappended line' filename;
* Replace text with variable:
sed -i 's/text/'$VARIABLE'/' filename;
 
===Web Stuff===
* Web Link Syntax:
<a href="<nowiki>http://www.google.com</nowiki>" target="_">Google</a>
* Redirect to specific URL (change ''url='' to desired path (i.e. <nowiki>http://appname/appdirectory</nowiki>):
<pre style="white-space: pre-wrap; word-break: keep-all;">echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>' > html/index.html
chown apache:users html/index.html</pre>
* Redirect to specific PHP file (change ''app.php'' to desired file):
<pre>cat > html/index.php << 'EOF'
<?php include("app.php") ?>
EOF</pre>
* Amahi Advanced User Warning
<pre style="white-space: pre-wrap; word-break: keep-all;"><p style="border:3px; border-style:solid; border-color:#FF0000; padding: 1em;"> <b>WARNING:</b> This application is designed for advanced users and should be used with caution. Use could disrupt and alter your server functionality. This application is not endorsed or officially supported by Amahi.</p></pre>
* Wiki collapsible code
:Select ''Item Collapse''
<div class="mw-collapsible mw-collapsed" data-collapsetext="{{int:screenshot}}" style="width:400px">
:This is a test.
</div><br \>
<pre>
Select ''Item Collapse''
<div class="mw-collapsible mw-collapsed" data-collapsetext="{{int:screenshot}}" style="width:400px">
This is a test.
</div><br \>
</pre>
* Restrict <nowiki><pre></nowiki> Width
<nowiki><pre style="white-space: pre-wrap; word-break: keep-all;">text</pre></nowiki>
 
===Miscellaneous===
* Extract files to path...preserving unchanged or newer files
tar -xzpf file -C path --keep-newer-files
* Retrieve System Information
apaste --sysinfo
* Replace string in files
find ./ -type f -exec sed -i 's/string1/string2/' {} \;
* Suppress Console Output (to include errors):
command &> /dev/null 2>&1
* Kill process:
kill $(ps -gaux | grep 'process name' | awk '{print $2}')
* Patch Comment:
# FIXME - this needs to be hosted in dl.amahi.org prior to going live!
* AmahiSync Web Link:
<nowiki>http://username.amahi.me/Public/filename</nowiki>
* Google Drive Web Link:
<nowiki>wget "https://drive.google.com/uc?export=download&id={FILEID}"</nowiki> -O {FILENAME}
* Patch Diff:
<pre>diff -r -N -b -u html.orig html > app-patch.diff</pre>
<pre>patch -p0 -E < app-patch.diff</pre>
* Cat EOF:
:with variables
cat > test << EOF
... text goes here ...
EOF
and :without variables
cat > test << 'EOF'
... text goes here ...
* Run as First Admin User:
<pre>su $FUSER -c command</pre>
* Redirect to specific URL (change ''url='' to desired path (i.e. <nowiki>http://appname/appdirectory</nowiki>):Change ownership of symbolic link<pre>echo '<!DOCTYPE HTML PUBLIC " chown -//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Your Page Title</title><meta http-equiv="REFRESH" content="0;url=httph username:users /var/www.the-domain-you-want-to-redirect-to.com"></HEAD><BODY>Optional page text here.</BODY><hda/HTML>' > htmlfiles/index.htmlsharechown apache:users html/index.html</pre>
===Netboot [[Netboot_Template|App Template]]===
# Once exactly one service is picked. It's the name of the service.
# Name is required, and it may be optionally followed by a PID file path
# IfWith the following features:#* File If the file path doesn't start with / it's relative to /var/run/ (i.e. named:named/named.pid -> /var/run/named/named.pid)#* If the PID file path starts with /, then it's used as is#* No If no PID file path specified, then the PID file is assume to be /var/run/<name>.pid#* Does If it does not exist, otherwise the platform will do a <i>pgrep</i> <name>#* Returns If it returns something, it's assumed it will be valid PIDs for that service
# Not recommended as <i>pgrep</i> may pick up other processes running by a name containing <name>, e.g., ssh-agent.
 
===systemd service template===
See [http://blog.hqcodeshop.fi/archives/93-Handling-varrun-with-systemd.html Handling /var/run with systemd] for details.
[Service]
Type=forking
# Run ExecStartPre with root-permissions
PermissionsStartOnly=true
ExecStartPre=-/usr/bin/mkdir -p /var/run/dhis
ExecStartPre=/usr/bin/chown -R nobody:nobody /var/run/dhis/
# Run ExecStart with User=nobody / Group=nobody
ExecStart=/usr/sbin/dhid -P /var/run/dhis/dhid.pid
PIDFile=/var/run/dhis/dhid.pid
=== Test Checklist ===
==== Amahi Greyhole Test Checklist ====
1. Install Greyhole and verify no errors
 
rpm -Uvh URL
 
2. Check the Greyhole log for normal behavior
 
tail -f /var/log/greyhole.log
 
3. Stop, start, and restart the service, checking status for errors
 
systemctl stop amahi-greyhole.service
systemctl status amahi-greyhole.service
systemctl start amahi-greyhole.service
systemctl status amahi-greyhole.service
systemctl restart amahi-greyhole.service
systemctl status amahi-greyhole.service
 
4. Add a few files to Greyhole-enabled shares and check log for errors
 
tail -f /var/log/greyhole.log
 
5. At command line, execute the following which should yield 1 line with 3 numbers
 
greyhole-dfree
 
6. Verify in dashboard that Disk Partitions appear correctly
 
7. Reboot machine to ensure Greyhole starts without errors
 
ps guax | grep greyhole
tail -f /var/log/greyhole.log
 
8. Verify version of amahi-greyhole installed is correct
 
greyhole
 
9. Delete 1 file and check log for activity
 
tail -f /var/log/greyhole.log
 
10. Force greyhole to manage files and check log for errors
 
greyhole -f
tail -f /var/log/greyhole.log
 
11. Empty the attic and it should reflect something being removed.
 
greyhole -a
 
12. Check log to verify still working correctly and should show sleeping.
 
tail -f /var/log/greyhole.log
 
If any of the steps are not correct, there is most likely a bug. This testing must be on an Amahi 7 machine with the latest Amahi platform and no OS updates installed. Basically it should appear like a new install.
==== Amahi Platform =Release Checklists ===Things to test in new platform releases* Greyhole ([https://bugs.amahi.org/issues/1344 Bug #1344])
# users#*creation#*deletion#*adding public key#*make user admin#*make sure admin cannot remove self from being admin#shares area#* create a share, delete it#* set all permissions, test them Platform (at the very least visually in /etc[https:/samba/smb.conf)# disks area#* shows right disks and partitions# apps installation#* with server#* with share#* with database#* theme#* plugin-based apps# network settings#* create alias#* create static IP#* go to settings, verify that you can change the DNS provider, including custom # # settings#* in settings, verify that the lease time can be changed#* in settings, verify (quickly) that you can change the gateway# settings area#* make sure the language can be changed#* make sure advanced settings work and other things show up in other tabs (ebugs.gamahi. shares -- suggest you open that one in a separate tab and refresh)#* make sure it's possible to restart the server and power it off#* make sure guest dashboard is accessible when the option is checked#* go to the themes subtab and change themesorg/issues/1386 Bug #* go to the servers area, and see if you can stop, restart, unmonitor and otherwise permanently stop a harmless server (not a critical server like hda-ctl, mysql, apache, etc.1386]).
12,424

edits