qnap qpkg lecture topic : create your qpkg

47
SUMMARY Foreword Guidelines for the QNAP QPKG system v1 Overview Development recommendations Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service

Upload: rory

Post on 09-Jan-2016

142 views

Category:

Documents


3 download

DESCRIPTION

QNAP QPKG Lecture Topic : Create your QPKG. SUMMARY Foreword Guidelines for the QNAP QPKG system v1 Overview Development recommendations Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service. Tentative Agenda. Second Meeting. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: QNAP QPKG Lecture Topic : Create your QPKG

SUMMARY Foreword Guidelines for the QNAP QPKG system v1

Overview Development recommendations

Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service

Page 2: QNAP QPKG Lecture Topic : Create your QPKG

20 avril 2023

Workshop (2.5 hours): - Take XDove and package- Code reading

Workshop (2.5 hours): - Take XDove and package- Code reading

This slide presentation (3 hours)This slide presentation (3 hours)

Workshop (30 mins): - Get familiar with the folder structure of the

sample-qpkg-hello_qnap template

Workshop (30 mins): - Get familiar with the folder structure of the

sample-qpkg-hello_qnap template

XDove example presentation (30 mins)XDove example presentation (30 mins)

How to select your 2nd QPKG

Review the list of Apps to be packaged

How to select your 2nd QPKG

Review the list of Apps to be packaged

First MeetingFirst Meeting

Second MeetingSecond Meeting

Workshop (1 hour): - Package your first Hello QPKG

Workshop (1 hour): - Package your first Hello QPKG

Q&A regarding previous session

Asterisk example

Q&A regarding previous session

Asterisk example

Wrap-up (1 hour)- Q&A about issues, points to clarify

Wrap-up (1 hour)- Q&A about issues, points to clarify

Page 3: QNAP QPKG Lecture Topic : Create your QPKG

Cloud Computing and SaaS (Software as a Service)

These are two major strategic developments that will disrupt the information systems business by decoupling the Usage from the Infrastructure.

◦ USAGE = Saas (pronounced 'sass') is a model of software deployment whereby a provider licenses an application to customers for use as a service on demand.

Applications are hosted on the provider web servers Applications are loaded on demand and disabled after use or contract expiration.

SaaS is pushed by: Need to use/pay software license on-demand Improve application’s inter-connections by using the same tools among large groups of users

◦ INFRASTRUCTURE = Cloud computing is a way of computing, via the Internet, that broadly shares computer resources instead of using software or storage on a local PC.

NOTE: confusion may arise because Cloud computing providers also promote a SaaS offer to run on their infrastructure.

Cloud computing is pushed by: Need to improve the CADE - Corporate Average Data center Efficiency

waste of energy to power large, numerous, under-used data center (be greener) Share maintenance costs of data center Scale user infrastructure to what they really need (computing power and time slots)

20 avril 2023

Page 4: QNAP QPKG Lecture Topic : Create your QPKG

QNAP QPKG

◦ QPKG may be seen as SaaS-like applications

Provide a wide variety of applications to the end-users

Groups of applications are tailored by market segment (usage)

EZ to install/remove by non-technical end-users

Generic (database, mail) or specific (ERP) applications

Open system that enables OS communities to develop QPKGs

Currently all QPKG are released for free to NAS users

QPKG system will evolved in the near future to improve

QPKG available today

◦ Official QPKG

MLDonkey, SSOTS (SlimServer on Turbo Station), Optware IPKG (Itsy Package Management System), phpMyAdmin, Joomla,

WordPress, SABnzbd+, AjaXplorer, Tomcat, XDove, Asterisk, JRE 6 (Java Runtime Environment),

◦ Beta QPKG

rTorrent++, NZBGet, IceStation, Plugmedia (Multimedia Station), Perl, Piwik, phpBB3, Unrealircd, Q-Ext, Q-Sims (Virtual

World Simulator), eyeOS, Magento, OpenX, MediaWiki, PostgreSQL

Page 5: QNAP QPKG Lecture Topic : Create your QPKG

To install a new application from a QPKG, the USER:

1. Use the RSS feed to download the QPKG from the QNAP servers

2. Shall upload the QPKG on the NAS thanks to the QPKG page of the NAS Administration web UI

3. Proceed with the installation by clicking the INSTALL button

QPKG

2 3

1

Page 6: QNAP QPKG Lecture Topic : Create your QPKG

QPKG Application management

1. Once installed, the Application may be startedExecute the script : ./qpkg_name.sh start

2. The Application may be stoppedExecute the script : ./qpkg_name.sh stop

3. The QPKG may be removedExecute the script : ./.uninstall.sh

4. The user can access the Application web interface (if any)The URL link is active once the QPKG is Enabled

1 2 3

4

Page 7: QNAP QPKG Lecture Topic : Create your QPKG

In order to develop QPKG applications, you will need to deal with:

◦ Linux Bash scripts For installation and administration tasks

◦ PHP language Web interface code writing JQuery for Rich Interface Applications Smarty* for web page skin management TinyMCE* as user text editor

◦ Linux cross-compilation understanding Compile some application from source

◦ CGI script understanding To issue admin commands from the web interface

◦ LOCALE and Internationalization understanding To enable the QPKG to support several selectable languages To enable the QPKG to support help pages in different languages

◦ Wiki page writing To make available online help pages To maintain a troubleshooting page To provide additional information about the QPKG (eg. case study, technology information, etc…)

◦ Technical English For code comments and QPKG help pages For Applications Notes and Wiki pages

* To be discussed

Page 8: QNAP QPKG Lecture Topic : Create your QPKG

GUIDELINESFor

QNAP QPKG system v1 development

Page 9: QNAP QPKG Lecture Topic : Create your QPKG

SUMMARY Foreword Guidelines for the QNAP QPKG system v1

Overview Development recommendations

Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service

Page 10: QNAP QPKG Lecture Topic : Create your QPKG

Use SVN for versioning◦ Repository svn://…….◦ Use of TRAC (TBD)(TBD)

Use Bugzilla for bug tracking◦ (TBD)(TBD)

Use collaborative environment◦ To share documents◦ To get support from QNAP

Use QPKG template◦ sample-qpkg-hello_qnap

Page 11: QNAP QPKG Lecture Topic : Create your QPKG

There are several levels of packaging:

◦ Packaging applications as a PHP web applications (eg Joomla). The QPKG provides: an installation/remove script to copy/remove the PHP code A folder with the web files an URL link to access the application from the QPKG Interface

◦ Packaging applications already existing as IPKG modules (eg Asterisk). The QPKG provides: an installation script for the IPKG a script to Start/Stop the application An URL link to access the Web server/GUI if any

◦ Packaging an already existing Debian x86/ARMEL package (eg Mono). The QPKG provides: A folder with the binary/libs downloaded from the Deb pkg an installation/remove script to copy/remove the files and recreate the symbolic links to the libs a script to Start/Stop the application An URL link to access the Web server/GUI if any

◦ Packaging an application from a source code exists (eg FreeSwitch). The QPKG provides: A folder with your compiled binaries A folder with the binary/libs downloaded from the Deb pkg an installation/remove script to copy/remove the files and recreate the symbolic links to the libs a script to Start/Stop the application An URL link to access the Web server/GUI if any

◦ BUT most of the time you will have to (eg Plugmedia): Use some IPKG to install libs Compile some source code to get the application running Write/modify script for the QPKG installation/removal Write/modify script to start/stop the application Develop a PHP interface to enable the user to configure the application

Page 12: QNAP QPKG Lecture Topic : Create your QPKG

Creating a QPKG archive◦ Once the code is written, we proceed

with the QPKGing

The build.sh script is launched to manage the QPKG creation. It will call the qpkg_build_QNAP.sh script to finish up the packaging.

Compression of the relevant files for the selected NAS model into the archive npkg_name.tar.tgz

Add the installation script renamed as qinstall.sh for the selected NAS model.

Add the built-in.sh script to enable the QPKG archive self-extraction

The QPKG archive file is stored into the /build folder

WARNING: keep consistency between QPKG name and file naming (QPKG name may be retrieved from script name.

qpkg_name-version.qpkgqpkg_name-version.qpkg

built-in.sh

qinstall.sh

npkg_name.tar.tgz

build.sh

DO NOT MODIFYOnly configure

Built-in.sh

DO NOT MODIFY

qpkg_build_QNAP.sh

DO NOT MODIFY

under /apps/scritps folder

un

de

r /a

pp

s/q

pk

g_

na

me

fo

lde

r

under /apps/build folder

QPKG

+

X

QPKG filesPHP, binaries, images,Scripts, css, JS, etc.

START

+2

3

4

1

5

1

2

3

4

5

qinstall_x09.shqinstall_x19.sh

qinstall_x86.sh

qinstall_all.sh

Installation scripts

Page 13: QNAP QPKG Lecture Topic : Create your QPKG

Tree structure for QPKG development [MANDATORY]

apps folder All QPKG applications

◦ /qpkg_name folder (for one Apps) build.sh script used to create the QPKG build- SYNTAX= ./build.sh [arm-x09|arm-x19|x86|all] qinstall_xxx.sh scripts for the QPKG installation (one for each NAS model)

The relevant qinstall_xxx.sh will be rename as qinstall.sh and embeded in the QPKG build /src-all folder

All the files for a platform independent applications

/src-shared folder Every files that are platform independent – eg PHP files for a web interface Icons files Start/Stop script and .uninstall.sh script

/src-x09 folder Every files required by Chrooted ARMEL platforms (TS-109/209/409) Libs and/or IPKG modules CGI files compiled or not. CGI file to pass bash cmd from PHP with admin status

/src-x19 folder Every files required by ARMEL platforms (TS-119/219/419) Libs and/or IPKG modules CGI files compiled or not. CGI file to pass bash cmd from PHP with admin status

/src-x86 folder Every files required by Intel platforms (TS-509/809/239/439/639...x59) Libs and/or IPKG modules CGI files compiled or not. CGI file to pass bash cmd from PHP with admin status

/build folder Receive the QPKG archives for distribution created by the ./build.sh <model> cmd A build is made of a build-in.sh script and a tar file that gather the folder above according to the NAS type.

/script folder Hosts the scripts to create the build – DO NOT MODIFY built-in.sh is a bootstrap included into the QPKG to make it self-extracted and launch the installation qpkg_build_QNAP.sh is the builder script to create the QPKG archive

Page 14: QNAP QPKG Lecture Topic : Create your QPKG

/apps # QPKG application folder|-- /hello_qnap # Sample QPKG app (Hello QNAP)

|---- build.sh # QPKG build script |---- qinstall-x09.sh # QPKG install script for x09 series NAS |---- qinstall-x19.sh # QPKG install script for x19 series NAS |---- qinstall-x86.sh # QPKG install script for x86 series NAS |---- qinstall-all.sh # QPKG install script for NAS independant app |---- qpkg.cfg # QPKG package information |---- /src-all # for non hardware-dependent apps (eg, web apps)

|---- /src-shared # for non hardware-dependent common files|---- .qpkg_icon.gif # Main QPKG icon (display in admin backend) |---- .qpkg_icon_80.gif # QPKG icon shown in pop-up window|---- .qpkg_icon_gray.gif # Grayed-out QPKG icon (when disabled) |---- /hello_qnap # Stores QPKG webUI files

|---- index.php # QPKG webUI files |---- hello_qnap.sh # QPKG app start/stop script (/etc/init.d/hello_qnap.sh)|---- .uninstall.sh # QPKG uninstall procedures

|---- /src-x09 # QPKG app folder (for arm-x09 series NAS)|---- /bin # Stores QPKG binaries

|---- hello_qnap # QPKG main app binary (for arm-x09 series NAS)|---- hello_qnap.conf # QPKG main app config file

|---- /src-x19 # QPKG app folder (for arm-x19 series NAS)|---- /bin # Stores QPKG binaries

|---- hello_qnap # QPKG main app binary (for arm-x19 series NAS)|---- hello_qnap.conf # QPKG main app config file

|---- src-x86 # QPKG app folder (for x86 series NAS)|---- /bin # Stores QPKG binaries

|---- hello_qnap # QPKG main app binary (for x86 series NAS)|---- hello_qnap.conf # QPKG main app config file

/build # Destination build folder/scripts # Stores QPKG build scripts

|---- built-in.sh # QPKG build scripts|---- qpkg_build_QNAP.sh # QPKG build scripts

Page 15: QNAP QPKG Lecture Topic : Create your QPKG

Help and Documentation

◦ Code files MUST BE documented in English

◦ User help pages shall support Internationalization (selectable languages)

◦ Application user interface (web GUI) shall have help pages/pop-ups to provide additional information to the user (English, Chinese)

◦ Applications Notes for each QPKG must be accessible from QNAP website

◦ User documentation, application examples, troubleshooting sections may be gathered as wiki pages

◦ Also consider to translate the application in Chinese if not available Translate the Web GUI Translate the Help pages any Translate the Installer if any Optionally, you can translate (low priority)

The wiki pages (shall be at least in English) The online help if any The examples

◦ Languages (speakers) English – mandatory ( 920 millions) Chinese (1.12 milliard) Hindi ( 740 millions) French ( 600 millions) Arabic ( 482 millions) Spanish ( 380 millions)

Page 16: QNAP QPKG Lecture Topic : Create your QPKG

Full testing requires the QPKG to be created◦ You may install the QPKG manually (see §3)

Application testing can be done “in situ” by duplication of the QPKG src-xxx folders◦ Copy the relevant src-xxx folders for a specific NAS model under:

/share/xx0_DATA/.qpkg/<your_qpkg>◦ Create the symbolic links and set the permissions◦ Run the application from this location

Installation debugging is tricky◦ Once the QPKG is created copy the QPKG into /share/Public◦ Start the installation using ./your_qpkg.qpkg (self-extraction)◦ The QPKG installs on your NAS the same way as if it was uploaded and installed

from the QPKG interface ◦ Monitor the installation and check for failure

◦ qinstall_xxx.sh script debugging: There is no easy way to debug the installation script If the qpkg installation fails use ./built.sh <model> debug and check the temporary folder:

/mnt/HDA_ROOT/update_pkg/tmp You will find the qinstall.sh, qpkg-name.tgz, qpkg.cfg and common.sh Edit and modify the qinstall.sh to fix bug Copy the working version back to your SVN

Page 17: QNAP QPKG Lecture Topic : Create your QPKG

Recommendations (TBD)◦ Avoid folder removal (rm –R /xxx/$VAR and VAR is empty due to bug or

user entry error)◦ Log your code execution

into a log file for debugging (using a tee instruction for example) Report critical errors using the QNAP Admin log system (/sbin/write_log) Keep log file size under control (tail or rotation files)

◦ To improve coding, use “pair programming” on sensitive pieces of code◦ Use code review across project teams◦ Cross projects with your colleagues for beta tests

◦ Suggestion : Agile Software development methodology (e.g. Scrum) List all tasks into a backlog Extract a backlog subset which can provide in a fixed 2 weeks timeslot, a

functional* product with the selected features (Sprint) Reiterate the Sprints until the backlog gets empty

* Functional means, all selected features for the Spring have been implemented, tested and validated like in a final product

Page 18: QNAP QPKG Lecture Topic : Create your QPKG

Minimum testing to be performed on a QPKG for each NAS models (series) before Alpha release◦ Test QPKG installation – qinstall.sh script◦ Test QPKG removal - .uninstall.sh script (and check for residue after removal such as broken

symblink )◦ Test QPKG Enable/Disable - <your_qpkg>.sh script◦ Test QPKG installation and upgrade◦ Test Web GUI if any◦ Test for security issues if the QPKG needs to support some restrictions (password, account, multi-

users,…)◦ Test cased can be user cases and may also be providing in the user’s document◦ Any other tests to ensure the QPKG to meet the requirements

If your QPKG (A) is to be used by an other QPKG (B) (eg. PostgreSQL)◦ Test your QPKG (A) with the QPKG (B)◦ Test that the QPKG (A) removal will not destroy data that belong to QPKG (B)◦ For the time being there is no way to prevent the removal of QPKG (A) if QPKG (B) is still installed

Testing with IPKG modules installation◦ Shall you QPKG use IPKG modules, you must test the correct installation of modules◦ If a pre-installation is enabled (see next slides for ipkg modules installation) check for failure and

possible remote ipkg installation from Internet

QPKG shall be released for Production◦ Ensure to fully passed the Alpha and Beta levels

Page 19: QNAP QPKG Lecture Topic : Create your QPKG

SUMMARY Foreword Guidelines for the QNAP QPKG system v1

Overview Development recommendations

Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service

Page 20: QNAP QPKG Lecture Topic : Create your QPKG

Standard QPKG installation procedure1. Download the QPKG from the QNAP servers 2. Upload the QPKG on the NAS with the NAS Administration web UI3. Install by clicking the INSTALL button

Manual QPKG installation procedure1. Copy the QPKG on the NAS (eg /share/Public)2. Auto-run the QPKG - ./qpkg_name_ver_model.qpkg

Once the installation has been launched,◦ The QPKG is copied into a temporary folder

/mnt/HDA_ROOT/update_pkg/tmp

◦ The QPKG is self-launched to: Extract the embedded tar archive thanks to the built-in.sh bootstrap script Execute the qinstall_xxx.sh script to proceed with the installation Remove the files from th temporary folder

Page 21: QNAP QPKG Lecture Topic : Create your QPKG

◦ The qinstall.sh scriptqinstall.sh script has several functions to handle the different situations:

UtilsUtils Defines section All bash commands used

SystemSystem Defines section Required by the QPKG system

QPKG InfoQPKG Info section Source the common variables defined in config.cfg

pre-install()pre-install() – Add you code here Routines to install or check for libs required by the QPKG application

install_routines()install_routines() – Add you code here Routines to execute during installation The TAR file extraction is handled in the install() routine

post-install()post-install() – Add you code here Routines to clean-up, remove temp file, etc …

pre-update()pre-update() – Add you code here If an update is detected (QPKG already installed) this routine shall receive the code to backup data for example.

update_routines()update_routines() – Add you code here Update the application files concerned by the upgrade procedure

post-update()post-update() – Add you code here If an update is detected (QPKG already installed) this routine shall receive the code to restore the previously backup

data for example. your_routine()your_routine()

You may need to add your own routine to keep the script more legible

Page 22: QNAP QPKG Lecture Topic : Create your QPKG

◦ The qinstall.sh scriptqinstall.sh script structure – cont’d:

_exit() _exit() – DO NOT MODIFY Exit the script and return a message in the NAS log

find_base()find_base() – DO NOT MODIFY Get the shared folder in QPKG_BASE=[HDx_DATA or MDx_DATA] Set the QPKG_INSTALL_PATH and QPKG_DIR

link_start_stop_script()link_start_stop_script() – DO NOT MODIFY Creates the link to enable to start/stop the application from the QPKG administration interface and during the boot if enabled

register_qpkg()register_qpkg() – DO NOT MODIFY Register the QPKG into the QPKG database

check_existing_install()check_existing_install() – DO NOT MODIFY Detect which kind of installation to perform (install or upgrade)

copy_qpkg_icons()copy_qpkg_icons() – DO NOT MODIFY Move the QPKG icons to their final location

start_apache()start_apache() – DO NOT MODIFY Start the Apache server if not running – WARN: will not restart a run Apache server

create_req_symlinks()create_req_symlinks() – Add you code here Create the symbolic links needed by the appllication

set_req_permissions()set_req_permissions() – Add you code here Set the permissions on files and folders

install()install() – DO NOT MODIFY UNLESS THERE IS A VERY GOOD REASON Proceed with the files copy A folder for each QPKG is created under /share/xx0_DATA/.qpkg (where xx stands for HD in std mode or MD in RAID mode)

The qinstall_xxx.sh script is no longer available after installation. QPKG removal is managed by the .uninstall.sh script.

Page 23: QNAP QPKG Lecture Topic : Create your QPKG

The .uninstall.sh script (Please, leave the place clean after QPKG removal)◦ The script is stored under the QPKG src-shared folder◦ The .uninstall.sh script is used during QPKG removal operation◦ There is one uninstall.sh script for all NAS type (use model detection if needed)

◦ Keep in mind : To set the QPKG name in QPKG_NAME variable – there is no easy way to retrieve safely and automatically the

name To remove dead symbolic links that you have create for your application

Recreating over an existing symblink may cause some issues DO NOT remove libs and/or IPKG modules you have installed. They may be used now by other QPKG applications To remove all configuration files, temporary files or folders that you have created for the QPKG applications and

which are not located under the QPKG root folder – clean your mess ! DO NOT delete database system that you have installed but only the database/tables that you have created Be careful while removing users/groups to be sure they are not used by other applications

Page 24: QNAP QPKG Lecture Topic : Create your QPKG

The . start/stop script qpkg_name.sh and qpkg_name.conts scripts◦ The qnap_name.sh script is stored under the apps/qpkg_name/src-shared folder

◦ The qnap_name.sh script is used to Start the application

When the user press the Enable button on the QPKG Administration page When the NAS reboot if the QPKG has been enabled

Stop the application When the user press the Disable button on the QPKG Administration page When the user press the Remove button on the QPKG Administration page

Restart the application Proceed with a Stop and a Start

◦ The qnap_name.sh script does not need to be modified – modifications are placed into the qnap_name.sh scriptSpecific code is placed into the qnap_name.conf bash file for each NAS version under the src-xxx foldersThe qnap_name.conf file is sourced in the qnap_name.sh file to take into account the specific code

Page 25: QNAP QPKG Lecture Topic : Create your QPKG

QPKG application icons◦ .qpkg_icon.gif Icon displayed on the QPKG admin GUI when QPKG is

Enabled◦ .qpkg_icon_gray.gif Icon displayed on the QPKG admin GUI when QPKG is Disabled◦ .qpkg_icon_80.gif Icon displayed in the QPKG control dialog box

◦ Icons are located into the apps/qpkg_name/src-shared folder◦ Icons are copied into the /home/httpd/RSS/images/ folder during installation◦ Please use QNAP graphical charter

.qpkg_icon.gif.qpkg_icon.gif

.qpkg_icon_gray.gif.qpkg_icon_gray.gif

.qpkg_icon_80.gif.qpkg_icon_80.gif

Page 26: QNAP QPKG Lecture Topic : Create your QPKG

You may have to develop a Application interface◦ This does NOT concern the Application PHP to be packages (e.g. Joomla PHP or PhpPgAdmin PHP interface)◦ It is related to YOUR PHP development to create an application configuration page for example.

◦ Configuration and variable in the config.php No hard coded paths please (use path variable in config.php) Variables for : params (Ports, URL, IP Add, …) etc.

◦ Recommended folders structure (to be discussed first and used by EVERYONE)

├─ /src-shared│ └─ /<qpkg_name> (web gui folder)│ ├─ index.php │ ├─ /database│ ├─ /system│ │ ├─ /_cache Smarty cache│ │ ├─ /_compiled Smarty accelerator│ │ ├─ /config configuration files│ │ ├─ /js JQuery, javascript code│ │ ├─ /libraries│ │ │ ├─ /smarty│ │ │ └─ /editors│ │ │ └─ /tiny_mce│ │ ├─ /langs folder for languages and help files│ │ ├─ /logs│ │ ├─ /inc folder for php files│ │ ├─ /themes│ │ └─ /default Default skin themes│ │ ├─ /css folder for CSS sheets│ │ ├─ /images folder for images and thumbnails│ │ ├─ /js javacript used by the default template only│ │ └─ /tpl (or inc)│├─ / src-xxx│ └─ /bin binaries not related to the application (eg. compiled bash) and cgi files

Required by SmartyRequired by TinyMCE

Page 27: QNAP QPKG Lecture Topic : Create your QPKG

PHP web interface◦ Has DOCTYPE = DTD XHTML 1.0 Transitional

Needed with JQuery DocType experts are welcomed to address this topic then use the same for all QPKG

◦ Has CHARSET = UTF-8◦ Is W3C compliant – please submit your pages for compliance◦ Has to support Internationalization for different languages

Set a default language to English using a configuration variable in your config.ini Have a language drop list to enable the user selection Optional : Use browser language detection to find the language or fallback to English

◦ Has to follow the QNAP graphical charter Get it from QNAP or mimic the v3 admin GUI Share graphics, CSS, Smarty templates between your QPKG devs

Shall you need a skinner please use Smarty◦ Default page size is 1024 x 768 px. ◦ Pages must be correctly displayed for this resolution and above.◦ Choose one stable version and keep it for all QPKG

Shall you need a RIA (Rich Internet Application) please use JQuery◦ Do not mods the JQuery (tweek the code) to allow future upgrades

Page 28: QNAP QPKG Lecture Topic : Create your QPKG

For application that requires a user configuration◦ Use a QSA – Quick Start Assistant (Wizard) and support internationalization◦ 5/6 pages maximum◦ Users are non-technical persons

20 avril 2023

Page 28

Q-Sims QSA

Page 29: QNAP QPKG Lecture Topic : Create your QPKG

PHP web interface◦ User is seen as Guest (Apache)◦ User cannot issue admin commands using the exec PHP instruction

A workaround exists◦ Call a CGI code (bash) from the PHP using the wget instruction◦ The CGI code is executed with admin privileges◦ Execution may be incredibly slow because:

wget start to check for IPV6 then fallback to IPV4 after timeout Need to force IPV4 (use a variable to allow easy setup changes)

To do◦ Place you cgi files under the right folder:

apps/qpkg-name/src-shared – for ASCII cgi files apps/qpkg-name/src-xxx – for compiled cgi files CHMOD 755 qpkg_name.cgi Create a symbolic link from qpkg_name/bin/ folder to /home/httpd/qpkg_name

For debugging – unitary tests◦ Enable your CGI to be run from a shell command line

PHP code◦ Bash command as guest

$ret = exec(‘<bash command>’, $output);◦ Bash command as admin

$ret = exec(‘/usr/bin/wget "http://127.0.0.1:8080/<cgi_file>’, $output);Please see code examples to log the command output for debugging

Page 30: QNAP QPKG Lecture Topic : Create your QPKG

Basic restricted access control can be implemented◦ By using .htaccess file◦ And user from the /mnt/HDA_ROOT/.config/shadow file

Example:AuthName “This Access is Restricted" AuthType Basic AuthUserFile /mnt/HDA_ROOT/.config/shadow AuthGroupFile /dev/null <limit GET POST>

require user admin</Limit>

Protect the user’s data◦ Configuration folders must be restricted access

Eg .htaccess with deny all◦ Sensitive data must be gathered and stored in a protected folder◦ Protect user’s data against typing errors (confirm deletion/modifications,

enable rollback transactions, confirm password change, etc.)◦ Use poke-yoke to limit user errors or check user entry consistency

All default answers are Yes but one which is inverted must be set to No Do not display the ‘Continue’ button unless all fields are fill-in

◦ Implement backup/restore procedures for databases and sensitive data (.bak files, archive)

Page 31: QNAP QPKG Lecture Topic : Create your QPKG

MySQL database system is available on QNAP NAS◦ Recommanded by QNAP

PostgreSQL database system is available through a QPKG

SQLite is not available but through the IPKG modules

Page 32: QNAP QPKG Lecture Topic : Create your QPKG

Translated strings must be able to support :◦ HTML tags to improve the presentation◦ Foreign characters, Quotes

There are mainly two implementations today◦ Use of arrays (plugmedia)

Loaded as any PHP variable$lang = array('TRIER_PAR' =>'Trier par','ORDRE_TRIS' =>'Ordre de tris‘);

◦ Use of constants (XDove, q-ext, Q-Sims) Need to process the language text file (parser) Strings are gathered into sections (e.g. by pages, common, buttons, etc.) [common]

charset = iso-8859-15date_format = d F Y H:i:s

Translation files for the web interface and help◦ Are 2 different files◦ Translation of the apps interface may be used with default English help pages ◦ Do not rely on the LOCALE – NAS are seldom set to correct regionalization

# locale –aCen_US.utf8POSIX

◦ Q-Ext QPKG can install locales if needed but uis still Beta and for Tech. guys

Page 33: QNAP QPKG Lecture Topic : Create your QPKG

Ipkg - Itsy Package Management System, ◦ is a lightweight package management system designed for embedded devices that tries to resemble Debian's dpkg. ◦ is used in the Unslung operating system for the Linksys NSLU2 (Optware), in OpenWRT, Openmoko, WebOS, Gumstix, the iPAQ,

QNAP NASes, Synology NASes and elsewhere.

In normal operation ◦ IPKG modules are downloaded from the Internet

Ex. # ipkg install coreutils◦ IPKG modules are NAS model dependant (libs installation)

BUT we might prefer sometimes to install from a local folder to speedup the installation, to avoid the need for an Internet connection to secure the ipkg modules installation (bad Internet connection)

◦ Download and place the ipkg modules into an ipkg folder under your QPKG tree folder x86 : http://ipkg.nslu2-linux.org/feeds/optware/ts509/cross/unstable/ arm-x19: http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/ arm-x09: http://ipkg.nslu2-linux.org/feeds/optware/cs05q1armel/cross/stable/

◦ Install the ipkg modules in the “correct” order to respect module’s dependencies If you have not installed an ipkg module (a) when the ipkg module (b) is being installed and required the module (a), a download will be

performed.

◦ Installation from a local file: Ex. # ipkg install coreutils_8.4-1_arm.ipk

Folder structure to use with IPKG pre-installation◦ Store IPKG modules for each model under /apps/qpkg_name/src-xxx/ipkg folders◦ The IPKG module pre-installation is handled in the qinstall_xxx.sh script◦ An example of such implementation is availabe into the PosgreSQL QPKG

Page 34: QNAP QPKG Lecture Topic : Create your QPKG

Your Tests

Your Scripts

Your GUI 3rd party code

Create a QPKG

Web interfacerequired ?

Y

Build QPKG./build <nas_type>

Write a PHP interfaceto link to

/share/Qweb/qpkg_name

Add libs in qinstall_xxx.shIpkg install <lib>

System lib required ?

Y

IPKG module available ?

Y

Cross-compile sourceDDL QNAP toolchain

Debian lib available ?

Y

DDL, extract and store libsInstall libs in pre-install

qinstall_xxx.sh

Store the binariesInstall libs in pre-install

qinstall_xxx.sh

DDL the application codeIn the QPKG tree folder

Code compilation required ?

Y

Add pre-update & post-update code

in qinstall_xxx.sh

Data to savebefore upgrade ?

Y

Add pre-install & post-install code

in qinstall_xxx.sh

Add permissions & Symbolic links

in qinstall_xxx.sh

Wiite removal codein .uninstall.sh

Is the code for allNAS type ?

Y

Create other qinstall_xxx.sh

Check configuration file qpkg.cfg

Write languages and help files

Unitary & integration tests, validation and Alpha testing

Start beta testing with the QNAP community+ QNAP validation

QNAP NASEnd user

Support &Maintenance

Page 35: QNAP QPKG Lecture Topic : Create your QPKG

Toolchains

◦ X09 For x09 series (TS-109 TS-209 TS-409 TS-409U) Linux: 2.6.12.6-arm1 Marvell: Orion arm-none-linux-gnueabi NOTE : chrooted

◦ X19 For x10 series (TS-110 TS-210 TS-410) For x19 series (TS-119 TS-219 TS-219P TS-419P TS-419U) Linux: 2.6.30.6 Marvell: Kirkwood arm-none-linux-gnueabi NOTE : ARMEL (endian little)

◦ X86 For x39 series (TS-239 TS-259 TS-439 TS-459 TS-639 TS-659 TS-809 TS-809U TS-859 SS-439 SS-839) For one x09 model (TS-509 ) Linux: 2.6.24 Intel: Atom Compatible Debian / Ubuntu

Page 36: QNAP QPKG Lecture Topic : Create your QPKG

Some QPKGs (you must be registered to access the QPKG on the forum)◦ Forum: http://forum.qnap.com/viewforum.php?f=121◦ Asterisk:◦ XDove:

QPKGs with QSA (configuration wizard)◦ XDove◦ Q-Sims

QPKG that installs PHP web interface◦ Joomla, phpMyAdmin, AjaXplorer, XDove, PlugMedi@, PostgreSQL, MediaWiki, eyeOS◦ Tomcat,

QPKG with Ajax ◦ PlugMedi@, AjaXplorer

QPKG that installs binaries◦ JRE, Tomcat, Mono, FreeSwitch◦ SSOTS

QPKG with admin commands from PHP interface◦ Q-Ext, NZBGet, Q-Sims

QPKG that have required to compile source code◦ Mono, FreeSwitch

QPKG that use IPKG pre-installation process◦ PosgreSQL, PlugMedi@ v2

WARNING: QPKGs may have been developed with a different QPKG template and therefore may slightly differ in their folder structure and/or script functions organization

Page 37: QNAP QPKG Lecture Topic : Create your QPKG

SUMMARY Foreword Guidelines for the QNAP QPKG system v1

Overview Development recommendations

Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service IPBX

Page 38: QNAP QPKG Lecture Topic : Create your QPKG

Asterisk is a software implementation of a telephone private branch exchange (IPBX)

Asterisk can be installed through the IPKG module

Asterisk QPKG was created to:◦ Ease the installation using the NAS web interface instead of a SSH console (Putty)

◦ Enable/Disable the Asterisk application

◦ Made available a link to the Asterisk web GUI

Few files to modify from the QPKG template (use of an old template):/asterisk :

build.sh: script to create the Asterisk QPKG

qinstall-all.sh: script to install or upgrade the QPKG

.uninstall.sh: script to remove the QPKG

/src-all:

asterisk.sh; script to Enable/Disable the Asterisk application

◦ Forum: http://forum.qnap.com/viewforum.php?f=165

◦ Wiki: http://wiki.qnap.com/wiki/Asterisk

Page 39: QNAP QPKG Lecture Topic : Create your QPKG

Create variable to access the Asterisk web GUI and the configuration file

Install Asterisk application using the ipkg modules

Configure the Asterisk application

Page 40: QNAP QPKG Lecture Topic : Create your QPKG

20 avril 2023

Page 40

QPKG interfaceQPKG interfaceon the NAS web GUIon the NAS web GUI

Page 41: QNAP QPKG Lecture Topic : Create your QPKG

asterisk.sh .uninstall.sh

URL to Asterisk web GUI

Page 42: QNAP QPKG Lecture Topic : Create your QPKG

Asterisk QPKG documentation is availableat http://wiki.qnap.com/wiki/Asterisk

First logUser A/C: admin/passwordand change yourpasword

URL to Asterisk web GUI

Page 43: QNAP QPKG Lecture Topic : Create your QPKG

SUMMARY Foreword Guidelines for the QNAP QPKG system v1

Overview Development recommendations

Exercise #1 : Asterisk QPKG – IPBX Exercise #2 : XDove – All-in-one Mail Service

Page 44: QNAP QPKG Lecture Topic : Create your QPKG
Page 45: QNAP QPKG Lecture Topic : Create your QPKG

XMail is an Internet and Intranet mail server featuring:

◦ a (E)SMTP server – XMail and phpXmail for the web interface

◦ a POP3 server – Xmail

◦ A IMAP server - Dovecot

◦ 2x webmails applications RoundCube : IMAP only T-dah webmail (UebiMiau) : POP3/IMAP and Chat (between

registered users)

◦ A scheduled mail backup and restore functions

◦ A shared calendar (webcalendar) between users (registered user on IMAP server)

◦ A QSA – Quick Start Assistant

◦ Support 5 languages (English, French, German, Italian, Chinese Trad & Simp.) Forum: http://forum.qnap.com/viewforum.php?f=143 Wiki: http://wiki.qnap.com/wiki/XDove_Configuration

Page 46: QNAP QPKG Lecture Topic : Create your QPKG

Release for 2009 Chinese New year First QPKG with a QSA (6 pages Web installer)

◦ 1- Router configuration reminder◦ 2- XMail server and phpXmail configuration◦ 3- Domain and Postmaster account◦ 4- XMail SMTP server configuration◦ 5- User mailboxes creation◦ 6- Webmail configuration

Page 47: QNAP QPKG Lecture Topic : Create your QPKG

Question ? Advice ?

You may use the QNAP forum to get support and interact with

thousands of users from around the world

We hope you enjoy as much as we do.