line lengths

This commit is contained in:
Bob Mottram 2016-10-12 16:59:22 +01:00
parent 61b770ebb6
commit 12d5778ab7
2 changed files with 58 additions and 36 deletions

View File

@ -35,22 +35,25 @@ An example template for an app script is shown below. Copy this and add whatever
#!/bin/bash #!/bin/bash
# Copyright (C) Year YourName <YourEmail> # Copyright (C) Year YourName <YourEmail>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it
# it under the terms of the GNU Affero General Public License as published by # and/or modify it under the terms of the GNU Affero General
# the Free Software Foundation, either version 3 of the License, or # Public License as published by the Free Software Foundation,
# (at your option) any later version. # either version 3 of the License, or (at your option) any
# later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details. # GNU Affero General Public License for more details.
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General
# along with this program. If not, see <http://www.gnu.org/licenses/>. # Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
# 'full' includes your app in the full installation and you can also # 'full' includes your app in the full installation and you
# add other variants, separated by spaces. The available variants will # can also add other variants, separated by spaces. The
# be detected automatically from the app scripts. # available variants will be detected automatically from the
# app scripts.
VARIANTS='full' VARIANTS='full'
SOME_IMPORTANT_CONFIG_VARIABLE='some important value' SOME_IMPORTANT_CONFIG_VARIABLE='some important value'
@ -78,7 +81,8 @@ function change_password_myappname {
function reconfigure_myappname { function reconfigure_myappname {
echo -n '' echo -n ''
# Do something to delete existing keys/identity and generate new ones # Do something to delete existing keys/identity and
# generate new ones
} }
function upgrade_myappname { function upgrade_myappname {
@ -95,13 +99,16 @@ function backup_local_myappname {
# To backup a directory # To backup a directory
backup_directory_to_usb $MYAPP_DATA_DIR myappname backup_directory_to_usb $MYAPP_DATA_DIR myappname
# if you need to backup data within individual user home directories # if you need to backup data within individual user
# home directories
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
echo $"Backing up myappname config for $USERNAME" echo $"Backing up myappname config for $USERNAME"
if [ -d /home/$USERNAME/.config/myappname ]; then if [ -d /home/$USERNAME/.config/myappname ]; then
backup_directory_to_usb /home/$USERNAME/.config/myappname myappname_users/$USERNAME backup_directory_to_usb \
/home/$USERNAME/.config/myappname \
myappname_users/$USERNAME
fi fi
fi fi
done done
@ -131,8 +138,10 @@ function restore_local_myappname {
fi fi
echo $"Restoring Vim config for $USERNAME" echo $"Restoring Vim config for $USERNAME"
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir myappname_users/$USERNAME restore_directory_from_usb $temp_restore_dir \
cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/ myappname_users/$USERNAME
cp -r $temp_restore_dir/home/$USERNAME/.config \
/home/$USERNAME/
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
set_user_permissions set_user_permissions
@ -177,7 +186,8 @@ function install_myappname {
create_database myappname "$MYAPPNAME_DB_PASSWORD" $MY_USERNAME create_database myappname "$MYAPPNAME_DB_PASSWORD" $MY_USERNAME
# If you need to create an onion address for the app # If you need to create an onion address for the app
MYAPPNAME_ONION_HOSTNAME=$(add_onion_service myappname 80 ${MYAPPNAME_ONION_PORT}) MYAPPNAME_ONION_HOSTNAME=$(add_onion_service myappname \
80 ${MYAPPNAME_ONION_PORT})
# Do any other configuration # Do any other configuration
# Here you might use $ONION_ONLY or $SOME_IMPORTANT_CONFIG_VARIABLE # Here you might use $ONION_ONLY or $SOME_IMPORTANT_CONFIG_VARIABLE
@ -195,7 +205,8 @@ function install_interactive_myappname {
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --title $"Change your avatar" \ dialog --title $"Change your avatar" \
--backtitle $"Freedombone Control Panel" \ --backtitle $"Freedombone Control Panel" \
--inputbox $"Enter a URL for an image. It should be approximately a square image." 8 75 2>$data --inputbox $"Enter a URL for an image. It should be " \
$"approximately a square image." 8 75 2>$data
sel=$? sel=$?
case $sel in case $sel in
0) 0)

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<!-- 2016-10-12 Wed 16:06 --> <!-- 2016-10-12 Wed 16:59 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title> <title></title>
@ -245,9 +245,9 @@ for the JavaScript code in this tag.
<center><h1>Developers Guide</h1></center> <center><h1>Developers Guide</h1></center>
<div id="outline-container-org27d5926" class="outline-2"> <div id="outline-container-orgacfcf5c" class="outline-2">
<h2 id="org27d5926">Adding extra apps</h2> <h2 id="orgacfcf5c">Adding extra apps</h2>
<div class="outline-text-2" id="text-org27d5926"> <div class="outline-text-2" id="text-orgacfcf5c">
<p> <p>
Suppose you have some internet application which you want to add to the system. To do this you need to create an app script which tells the system how to install/remove and also backup/restore. On an installed system the app scripts go into the directory: Suppose you have some internet application which you want to add to the system. To do this you need to create an app script which tells the system how to install/remove and also backup/restore. On an installed system the app scripts go into the directory:
</p> </p>
@ -278,22 +278,25 @@ An example template for an app script is shown below. Copy this and add whatever
<pre class="src src-bash"><span class="org-comment-delimiter">#</span><span class="org-comment">!/bin/</span><span class="org-keyword">bash</span> <pre class="src src-bash"><span class="org-comment-delimiter">#</span><span class="org-comment">!/bin/</span><span class="org-keyword">bash</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Copyright (C) Year YourName &lt;YourEmail&gt;</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Copyright (C) Year YourName &lt;YourEmail&gt;</span>
<span class="org-comment-delimiter">#</span> <span class="org-comment-delimiter">#</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">This program is free software: you can redistribute it and/or modify</span> <span class="org-comment-delimiter"># </span><span class="org-comment">This program is free software: you can redistribute it</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">it under the terms of the GNU Affero General Public License as published by</span> <span class="org-comment-delimiter"># </span><span class="org-comment">and/or modify it under the terms of the GNU Affero General</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">the Free Software Foundation, either version 3 of the License, or</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Public License as published by the Free Software Foundation,</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">(at your option) any later version.</span> <span class="org-comment-delimiter"># </span><span class="org-comment">either version 3 of the License, or (at your option) any</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">later version.</span>
<span class="org-comment-delimiter">#</span> <span class="org-comment-delimiter">#</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">This program is distributed in the hope that it will be useful,</span> <span class="org-comment-delimiter"># </span><span class="org-comment">This program is distributed in the hope that it will be useful,</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <span class="org-comment-delimiter"># </span><span class="org-comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <span class="org-comment-delimiter"># </span><span class="org-comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">GNU Affero General Public License for more details.</span> <span class="org-comment-delimiter"># </span><span class="org-comment">GNU Affero General Public License for more details.</span>
<span class="org-comment-delimiter">#</span> <span class="org-comment-delimiter">#</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">You should have received a copy of the GNU Affero General Public License</span> <span class="org-comment-delimiter"># </span><span class="org-comment">You should have received a copy of the GNU Affero General</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">along with this program. If not, see <a href="http://www.gnu.org/licenses/">&lt;http://www.gnu.org/licenses/&gt;</a>.</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Public License along with this program. If not, see</span>
<span class="org-comment-delimiter"># </span><span class="org-comment"><a href="http://www.gnu.org/licenses/">&lt;http://www.gnu.org/licenses/&gt;</a>.</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">'full' includes your app in the full installation and you can also</span> <span class="org-comment-delimiter"># </span><span class="org-comment">'full' includes your app in the full installation and you</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">add other variants, separated by spaces. The available variants will</span> <span class="org-comment-delimiter"># </span><span class="org-comment">can also add other variants, separated by spaces. The</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">be detected automatically from the app scripts.</span> <span class="org-comment-delimiter"># </span><span class="org-comment">available variants will be detected automatically from the</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">app scripts.</span>
<span class="org-variable-name">VARIANTS</span>=<span class="org-string">'full'</span> <span class="org-variable-name">VARIANTS</span>=<span class="org-string">'full'</span>
<span class="org-variable-name">SOME_IMPORTANT_CONFIG_VARIABLE</span>=<span class="org-string">'some important value'</span> <span class="org-variable-name">SOME_IMPORTANT_CONFIG_VARIABLE</span>=<span class="org-string">'some important value'</span>
@ -321,7 +324,8 @@ An example template for an app script is shown below. Copy this and add whatever
<span class="org-keyword">function</span> <span class="org-function-name">reconfigure_myappname</span> { <span class="org-keyword">function</span> <span class="org-function-name">reconfigure_myappname</span> {
<span class="org-builtin">echo</span> -n <span class="org-string">''</span> <span class="org-builtin">echo</span> -n <span class="org-string">''</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Do something to delete existing keys/identity and generate new ones</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Do something to delete existing keys/identity and</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">generate new ones</span>
} }
<span class="org-keyword">function</span> <span class="org-function-name">upgrade_myappname</span> { <span class="org-keyword">function</span> <span class="org-function-name">upgrade_myappname</span> {
@ -338,13 +342,16 @@ An example template for an app script is shown below. Copy this and add whatever
<span class="org-comment-delimiter"># </span><span class="org-comment">To backup a directory</span> <span class="org-comment-delimiter"># </span><span class="org-comment">To backup a directory</span>
backup_directory_to_usb $<span class="org-variable-name">MYAPP_DATA_DIR</span> myappname backup_directory_to_usb $<span class="org-variable-name">MYAPP_DATA_DIR</span> myappname
<span class="org-comment-delimiter"># </span><span class="org-comment">if you need to backup data within individual user home directories</span> <span class="org-comment-delimiter"># </span><span class="org-comment">if you need to backup data within individual user</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">home directories</span>
<span class="org-keyword">for</span> d<span class="org-keyword"> in</span> /home/*/ ; <span class="org-keyword">do</span> <span class="org-keyword">for</span> d<span class="org-keyword"> in</span> /home/*/ ; <span class="org-keyword">do</span>
<span class="org-variable-name">USERNAME</span>=$(<span class="org-sh-quoted-exec">echo</span> <span class="org-string">"$d"</span> | awk -F <span class="org-string">'/'</span> <span class="org-string">'{print $3}'</span>) <span class="org-variable-name">USERNAME</span>=$(<span class="org-sh-quoted-exec">echo</span> <span class="org-string">"$d"</span> | awk -F <span class="org-string">'/'</span> <span class="org-string">'{print $3}'</span>)
<span class="org-keyword">if</span> [[ $(<span class="org-sh-quoted-exec">is_valid_user</span> <span class="org-string">"$USERNAME"</span>) == <span class="org-string">"1"</span> ]]; <span class="org-keyword">then</span> <span class="org-keyword">if</span> [[ $(<span class="org-sh-quoted-exec">is_valid_user</span> <span class="org-string">"$USERNAME"</span>) == <span class="org-string">"1"</span> ]]; <span class="org-keyword">then</span>
<span class="org-builtin">echo</span> $<span class="org-string">"Backing up myappname config for $USERNAME"</span> <span class="org-builtin">echo</span> $<span class="org-string">"Backing up myappname config for $USERNAME"</span>
<span class="org-keyword">if</span> [ -d /home/$<span class="org-variable-name">USERNAME</span>/.config/myappname ]; <span class="org-keyword">then</span> <span class="org-keyword">if</span> [ -d /home/$<span class="org-variable-name">USERNAME</span>/.config/myappname ]; <span class="org-keyword">then</span>
backup_directory_to_usb /home/$<span class="org-variable-name">USERNAME</span>/.config/myappname myappname_users/$<span class="org-variable-name">USERNAME</span> backup_directory_to_usb <span class="org-sh-escaped-newline">\</span>
/home/$<span class="org-variable-name">USERNAME</span>/.config/myappname <span class="org-sh-escaped-newline">\</span>
myappname_users/$<span class="org-variable-name">USERNAME</span>
<span class="org-keyword">fi</span> <span class="org-keyword">fi</span>
<span class="org-keyword">fi</span> <span class="org-keyword">fi</span>
<span class="org-keyword">done</span> <span class="org-keyword">done</span>
@ -374,8 +381,10 @@ An example template for an app script is shown below. Copy this and add whatever
<span class="org-keyword">fi</span> <span class="org-keyword">fi</span>
<span class="org-builtin">echo</span> $<span class="org-string">"Restoring Vim config for $USERNAME"</span> <span class="org-builtin">echo</span> $<span class="org-string">"Restoring Vim config for $USERNAME"</span>
function_check restore_directory_from_usb function_check restore_directory_from_usb
restore_directory_from_usb $<span class="org-variable-name">temp_restore_dir</span> myappname_users/$<span class="org-variable-name">USERNAME</span> restore_directory_from_usb $<span class="org-variable-name">temp_restore_dir</span> <span class="org-sh-escaped-newline">\</span>
cp -r $<span class="org-variable-name">temp_restore_dir</span>/home/$<span class="org-variable-name">USERNAME</span>/.config /home/$<span class="org-variable-name">USERNAME</span>/ myappname_users/$<span class="org-variable-name">USERNAME</span>
cp -r $<span class="org-variable-name">temp_restore_dir</span>/home/$<span class="org-variable-name">USERNAME</span>/.config <span class="org-sh-escaped-newline">\</span>
/home/$<span class="org-variable-name">USERNAME</span>/
<span class="org-keyword">if</span> [ <span class="org-negation-char">!</span> <span class="org-string">"$?"</span> = <span class="org-string">"0"</span> ]; <span class="org-keyword">then</span> <span class="org-keyword">if</span> [ <span class="org-negation-char">!</span> <span class="org-string">"$?"</span> = <span class="org-string">"0"</span> ]; <span class="org-keyword">then</span>
rm -rf $<span class="org-variable-name">temp_restore_dir</span> rm -rf $<span class="org-variable-name">temp_restore_dir</span>
set_user_permissions set_user_permissions
@ -420,7 +429,8 @@ An example template for an app script is shown below. Copy this and add whatever
create_database myappname <span class="org-string">"$MYAPPNAME_DB_PASSWORD"</span> $<span class="org-variable-name">MY_USERNAME</span> create_database myappname <span class="org-string">"$MYAPPNAME_DB_PASSWORD"</span> $<span class="org-variable-name">MY_USERNAME</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">If you need to create an onion address for the app</span> <span class="org-comment-delimiter"># </span><span class="org-comment">If you need to create an onion address for the app</span>
<span class="org-variable-name">MYAPPNAME_ONION_HOSTNAME</span>=$(<span class="org-sh-quoted-exec">add_onion_service</span> myappname 80 ${<span class="org-variable-name">MYAPPNAME_ONION_PORT</span>}) <span class="org-variable-name">MYAPPNAME_ONION_HOSTNAME</span>=$(<span class="org-sh-quoted-exec">add_onion_service</span> myappname <span class="org-sh-escaped-newline">\</span>
80 ${<span class="org-variable-name">MYAPPNAME_ONION_PORT</span>})
<span class="org-comment-delimiter"># </span><span class="org-comment">Do any other configuration</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Do any other configuration</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Here you might use $ONION_ONLY or $SOME_IMPORTANT_CONFIG_VARIABLE</span> <span class="org-comment-delimiter"># </span><span class="org-comment">Here you might use $ONION_ONLY or $SOME_IMPORTANT_CONFIG_VARIABLE</span>
@ -438,7 +448,8 @@ An example template for an app script is shown below. Copy this and add whatever
<span class="org-keyword">trap</span> <span class="org-string">"rm -f $data"</span> 0 1 2 5 15 <span class="org-keyword">trap</span> <span class="org-string">"rm -f $data"</span> 0 1 2 5 15
dialog --title $<span class="org-string">"Change your avatar"</span> <span class="org-sh-escaped-newline">\</span> dialog --title $<span class="org-string">"Change your avatar"</span> <span class="org-sh-escaped-newline">\</span>
--backtitle $<span class="org-string">"Freedombone Control Panel"</span> <span class="org-sh-escaped-newline">\</span> --backtitle $<span class="org-string">"Freedombone Control Panel"</span> <span class="org-sh-escaped-newline">\</span>
--inputbox $<span class="org-string">"Enter a URL for an image. It should be approximately a square image."</span> 8 75 2&gt;$<span class="org-variable-name">data</span> --inputbox $<span class="org-string">"Enter a URL for an image. It should be "</span> <span class="org-sh-escaped-newline">\</span>
$<span class="org-string">"approximately a square image."</span> 8 75 2&gt;$<span class="org-variable-name">data</span>
<span class="org-variable-name">sel</span>=$<span class="org-variable-name">?</span> <span class="org-variable-name">sel</span>=$<span class="org-variable-name">?</span>
<span class="org-keyword">case</span> $<span class="org-variable-name">sel</span><span class="org-keyword"> in</span> <span class="org-keyword">case</span> $<span class="org-variable-name">sel</span><span class="org-keyword"> in</span>
0) 0)