My Cloud OS5 App Template

The following is a template that can be used to quickly create apps for My Cloud OS5. It contains everything required to build a basic app, but work will be needed to create an app that’s fully functional.

Each app script file has a specific purpose, and all app script files must exist, even if they aren’t being used. The apkg.rc file is used to configure the app during the installation process.

  • The "Package:" section determines the app package name. It MUST match the app folder name, and it CANNOT contain any spaces.
  • The "AddonShowName:" section determines the app display name. It CAN differ from the app package name, and it CAN contain spaces.

The remaining sections are described in the My Cloud OS 5 NAS App Guide, which also includes the mksapkg tool required to build app packages.

Required arguments will be automatically passed to scripts, where typical argument values and script execution order are shown in the examples below.

Configuration (apkg.rc):

Package: AppTemplate
Version: 1.0.0
Packager: Cerberus Software
Email:
Homepage:
Description: App template for development and testing.
Icon: AppTemplate.png
AddonShowName: App Template
AddonIndexPage: index.php
AddonUsedPort:
InstDepend:
InstConflict:
StartDepend:
StartConflict:
CenterType: 1
UserControl: 0
MinFWVer: 5.27.157
MaxFWVer:
IndividualFlag: 1
Hidden: off
AddonDefaultPort:
AddonDefaultGroup:
AddonDefaultUser:

Arguments:

UPLOAD="/mnt/HD/HD_a2/Nas_Prog/_install"
INSTALL="/mnt/HD/HD_a2/Nas_Prog/AppTemplate"

Install App:

$UPLOAD/install.sh $UPLOAD $INSTALL
$INSTALL/init.sh $INSTALL

Remove App:

$INSTALL/stop.sh
$INSTALL/clean.sh
$INSTALL/remove.sh $INSTALL

Enable App:

$INSTALL/start.sh

Disable App:

$INSTALL/stop.sh

Reinstall App:

$INSTALL/stop.sh
$INSTALL/clean.sh
$INSTALL/preinst.sh $INSTALL
$INSTALL/remove.sh $INSTALL
$UPLOAD/install.sh $UPLOAD $INSTALL
$INSTALL/init.sh $INSTALL

Tool Usage:

# mksapkg-OS5 --help

Usage: mksapkg-OS5 -E -s -m [model_name]

Supported model_name:
                WDMyCloud
                WDMyCloudEX4100
                WDMyCloudDL4100
                WDMyCloudEX2100
                WDMyCloudDL2100
                WDMyCloudMirror
                MyCloudEX2Ultra
                MyCloudPR4100
                MyCloudPR2100
                WDCloud

Build App:

# cd AppTemplate;
# ../mksapkg-OS5 -E -s -m MyCloudPR4100;

============================================
        mksapkg-OS5 version: 2.0
============================================
MinFWVer: [5.27.157]
MaxFWVer: []
Hidden: [off]
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
AppTemplate/
AppTemplate/stop.sh
AppTemplate/apkg.rc
AppTemplate/apkg.xml
AppTemplate/clean.sh
AppTemplate/init.sh
AppTemplate/install.sh
AppTemplate/preinst.sh
AppTemplate/remove.sh
AppTemplate/start.sh
AppTemplate/include.sh
AppTemplate/apkg.sign
AppTemplate/web/
AppTemplate/web/desc.xml
AppTemplate/web/index.php
AppTemplate/web/AppTemplate.png
AppTemplate/amd64/
AppTemplate/armhf/
***[../MyCloudPR4100_AppTemplate_1.0.0.bin(11012023)]

NAS type:               MyCloudPR4100
module name:            AppTemplate
module versioin:        1.0.0
packager:               Cerberus Software

header length:          14485
header checksum:        9C27D845

Add-ons "../MyCloudPR4100_AppTemplate_1.0.0.bin(11012023)" create!

Hi @Cerberus,

Have you opened a Support Case? If not opened, for more information, please contact the WD Technical Support team for the best assistance and troubleshooting:
https://support-en.wd.com/app/ask

Thanks for this. My desktop is MacOS/ARM, so I made a Dockerfile that allows me to run the build quickly and easily in an amd64 environment. I put it here:

I don’t believe my code violates any WD copyright since it doesn’t include the WD mksapkg binary itself, but rather downloads it from the link you gave.

2 Likes

You can also build apps on your PR4100 (amd64), which is where I do the vast majority of my work via an SSH connection.

My Cloud OS5 lacks the necessary components for compiling c or c++ code, but I’ve created an app (private for now) with all the required packages, and routinely compile Linux kernels, etc. The PR4100 is not as fast as my desktop computer, but it gets the job done.

2 Likes

Separate from this thread, I decided to attempt to build an app that I want on my PR4100 (Jellyfin). I updated my NAS to the 5.27.157 firmware just before I began my investigation (and read the release notes), so I know that OS5 now uses Bullseye as a base (albeit with a very out-of-date kernel).

The first reource that I found was the old WDCommunity repo. This looked like it needed a refresh, so I made my own version of it (not yet online) that made all the variables clearer for me etc. However, I can’t get anything that I built using my code to install on my NAS. I’m on Windows 11 so I’m using WSL.

Building on WSL’s Ubuntu 22 directly the mksapg-OS5 tool fails with a crypto package error:

Error setting cipher BF-CBC
40970C76397F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:../crypto/evp/evp_fetch.c:349:Global default library context, Algorithm (BF-CBC : 11), Properties ()

Though since I had no real intention of using this directly, I just added Docker and used a simple container to fix this problem:

FROM debian:bullseye

ENV LANG C.UTF-8

RUN apt-get update && apt-get install -y \
	build-essential \
	openssl \
	git \
	curl \
	wget \
	cmake \
	libxml2 \
	xz-utils \
	tar \
	gzip

COPY mksapkg-OS* /usr/bin/

# Volume that will point to the whole repository
VOLUME /data

WORKDIR /data

This works, and since I kept the WDCommunity features I’m able to build the binary packages from a single command with the source files added to an archive as a sanity check. These all seem to build correctly and checking the source tar.gz this looks correct.

However, when I add them to my NAS it says that it installs correctly, but when I actually look at what is created in the /mnt/HD/HD_a2/Nas_Prog/app_name directory, it’s just a single file: apkg.xml and nothing has been done nor hit the logs.

I thought that this was probably my mistake (I’m not a shell script person), so with a little bit of searching I found this thread and tried the AppTemplate above (without modification) and using the one-liner packaging command. This gives me exactly the same error.

Are you able to shed any light on this? I can put my code on Github if that’d be helpful, but I think this is more fundamental than that. Is it a new FW issue?

Any help is appreciated, I don’t tinker with my NAS much.

[The only other apps that I have are Plex (1.32.7.7621 - installed just before the FW upgrade, I think), Docker (20.10.14) and Entware (20.11.17). Plex is certainly working]

1 Like

Try working in a native Debian environment, no testing has been done using Ubuntu.

I don’t do Docker, so no testing has been done here either.

The WDCommunity repo was created by a third-party, and is entirely unrelated.

I just tested building the AppTemplate app package again, and it installed and ran without any problems. Again, you should work using a native Debian 11 (Bullseye) environment.

@Cerberus Thanks for the rapid reply! I’ll spin up an AWS Debian Bullseye instance and try the code there when I get the chance.

@koehn You’re building from a Mac using a dockerised process, but don’t have any such issue? If you get a spare 10 mins and wouldn’t mind modifying my Docker file slightly to see if it still runs for you that would be very helpful.

1 Like

Okay, I’ll bear that in mind, but I only have one Linux box and don’t really want to flash it if I can avoid that (full of work files). I’ll try the AWS build first.

What I’m trying to eliminate is the possibility that there is something wrong with my individual NAS since the firmware update before I destroy a perfectly good dev machine in the hopes of building an app that probably wont run on the device anyway!

1 Like

I’ve never had much luck messing with GRUB, so I’ve always stuck to just one distro per box. Risking all the files / config currently on that box isn’t something that I really want to do unless I absoluetly have to.

I have a PR4100 too, so I could try it on there I guess. It’ll have to be later tonight though.

For now, this is what my current build creates.

1 Like

Who said anything about messing with GRUB? I think you don’t understand the basics here. My Cloud OS5 is based on Debian 11 Bullseye, and all of my PR4100 boxes are running firmware version 5.27.157, not some specialized OS.

Since you have a PR4100, then you CAN build apps on it, with no modifications whatsoever. Just run the mksapkg program, it’s that simple.

The following example was performed on my PR4100, about 30 seconds ago.

# cd AppTemplate
# ../mksapkg-OS5 -E -s -m MyCloudPR4100
============================================
        mksapkg-OS5 version: 2.0
============================================
MinFWVer: [5.27.157]
MaxFWVer: []
Hidden: [off]
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
AppTemplate/
AppTemplate/stop.sh
AppTemplate/apkg.rc
AppTemplate/apkg.xml
AppTemplate/clean.sh
AppTemplate/init.sh
AppTemplate/install.sh
AppTemplate/preinst.sh
AppTemplate/remove.sh
AppTemplate/start.sh
AppTemplate/include.sh
AppTemplate/apkg.sign
AppTemplate/web/
AppTemplate/web/desc.xml
AppTemplate/web/index.php
AppTemplate/web/AppTemplate.png
AppTemplate/amd64/
AppTemplate/armhf/
***[../MyCloudPR4100_AppTemplate_1.0.0.231115.bin(11152023)]

NAS type:               MyCloudPR4100
module name:            AppTemplate
module versioin:        1.0.0.231115
packager:               Cerberus Software

header length:          14491
header checksum:        FCD86697

Add-ons "../MyCloudPR4100_AppTemplate_1.0.0.231115.bin(11152023)" create!

I don’t know enough to debug your issue; I don’t get the error you’re seeing. It looks like your Dockerfile is similar to my own, why don’t you try using mine?

From your project’s main directory, run:

docker run --rm -v "$PWD:/data" -e MODEL=<your MyCloud model> koehn/mycloud

This will leave place the resulting resulting .bin file in your project’s directory. Simply remove the parens from the end of it and deploy it to your device.

Or, as @Cerberus said, do your builds on your NAS.

1 Like

? I think that we’re talking at crossed purposes here. You’re telling me that I need to run these build processes on a native Debian 11 install… For that, I need some hardware to install it on (with cloud services such as AWS being untested)… With that option eliminated, it leaves me either needing to dual boot an existing machine (my options are my Windows box or my Linux box) or wipe one of them totally to install a fresh copy of Debian. My current Linux box is Manjaro and my Windows box is 11.

I can test this on my NAS itself (which is a very unusual Debian 11) by slowly, manually copying changed files over to it, but I’d really rather create a build process that’s repeatable from anywhere, but that I can manage from my OS / IDE so that I can automate it for new releases and change files quickly.

Again, I think that we’re talking at crossed purposes. I can simply manually upload the individual files if I want to manually tinker with my own NAS (I have the sources), but I want to be able to do is give this to others, and from a more long term view, actually give the build tool to package creators themselves so that it’s their responsibility for the WD builds (even if they don’t have a WD device). This requires that I come up with a build process that doesn’t rely on the device itself. As far as I know, this should work on any Debian, I’m just wondering why mine doesn’t.

My Dockerised Debian produces identical output to yours, just for some reason it doesn’t work.

1 Like

No, you don’t. As I said, just run the mksapkg program on your PR4100. I can’t explain it any more simply than that.

Ding, ding, ding!

Perhaps you are, but I’ve been crystal clear. Do it on the PR4100.

You have a Public share, right? Of course you do. Copy the mksapkg program to the Public share, then extract the AppTemplate.zip file to the same location.

  • /shares/Public/mksapkg
  • /shares/Public/AppTemplate

Then run the following commands and you’re off to the races.

  • cd AppTemplate;
  • ../mksapkg-OS5 -E -s -m MyCloudPR4100;

Again, I don’t do Docker, so you’re on your own there.

Just run this on the PR4100. Same issue. Which leaves me with: there’s something wrong with my NAS.

1 Like

Actually, and perhaps worryingly, no. I assume that I should? (though I’ve never used it). I have one shared folder (my user name).

It could, but it’s fairly unlikely given that it involved copying a folder, a single file and running them… Which also produced the output I would expect to see… Could you please share a blank build of the app (like I did) that you know works so that I can confirm it?

1 Like

To confirm that, would you mind uploading / sharing a working PR4100 bin file?

1 Like

Sharing a bin file won’t solve anything. But since you’re so insistent, here’s one I literally built a couple of minutes ago. Remove the .txt file extension before use.

MyCloudPR4100_AppTemplate_1.0.0.bin(11152023).txt (14.5 KB)

It works just fine. Again, you ABSOLUTELY MUST use an UNMODIFIED version of the AppTemplate.zip file for testing. Debugging broken apps after modifications is on you.

I really don’t know what’s up because I get the same error. Just literally the apkg.xml file and nothing else in the /mnt/HD/HD_a2/Nas_Prog/AppTemplate folder?!

BUT, no install errors or anything like that. I’m at a loss of what is wrong?

1 Like

Do you have entware installed? If so, remove it, then try again.

I do, just tried uninstalling it, but it didn’t actually uninstall. Just removed the menu item, but left all the files. Something weird is going on.

1 Like