Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide for building DTS for local network server #1131

Open
artur-rs opened this issue Nov 8, 2024 · 12 comments
Open

Guide for building DTS for local network server #1131

artur-rs opened this issue Nov 8, 2024 · 12 comments
Assignees
Labels
DasharoToolsSuite documentation Improvements or additions to documentation

Comments

@artur-rs
Copy link
Member

artur-rs commented Nov 8, 2024

DTS version

  • All

Question text

Forwarded request:

I want to build DTS for my local network server. It should run a script during system start on the same tty as the DTS menu. How can I achieve that? Just add my scripts to commands.sh and then build DTS?
I just to inject it in /meta-dts/meta-dts-distro/recipes-dts/dts/dts/dts but it's no longer there, I guess the way the menu is created is different now.

@artur-rs artur-rs added documentation Improvements or additions to documentation DasharoToolsSuite labels Nov 8, 2024
@DaniilKl
Copy link
Contributor

DaniilKl commented Nov 8, 2024

It seems like a Yocto recipe adding problem, not a problem related to any servers. Previously we held DTS scripts in meta-dts, that allowed for quick private script injections. Now we use a separate repo for DTS scripts (dasharo/dts-scripts), and therefore the recipe for it has been changed, that made it more difficult to add some private stuff.

There are two ways to handle this issue:

I could help with this exact problem - help to integrate the script. In this case, I need the information, what is the script purpose, what are the dependencies, how it should be installed, etc..

Or I could add recipe integration guide similar to the one from Zarhus.

@m-iwanicki
Copy link

m-iwanicki commented Nov 13, 2024

To keep it as similar as it was previously you could:

  1. Fork dts-scripts repo
  2. Commit your changes
  3. Change SRC_URI and SRCREV to point to your changes

Probably easiest and fastest change. You could even keep your dts-scripts changes locally and use git:///path/to/repo;branch=custom_branch;protocol=file

Another way would be to either add your custom script to meta-dts/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts/custom_script and in do_install inject call to this script with e.g. sed.
You can also inject whole file with sed e.g. sed -i '/^while/r custom_script' dts to inject contents of custom_script into dts after matched pattern in this case it's line starting with while or before matched pattern sed -i '/^while/e cat custom_script' dts (just replace with correct paths in do_install)

@DaniilKl
Copy link
Contributor

DaniilKl commented Nov 20, 2024

Our you can do it inside meta-dts:

  1. Create a subdirectory under dts-scripts directory and add your script:
λ mkdir meta-dts-distro/recipes-dts/dts-scripts/dts-scripts
λ vim meta-dts-distro/recipes-dts/dts-scripts/dts-scripts/your-script.sh
  1. Modify recipe for dts-scripts so it will install your script:
--- a/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
+++ b/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
@@ -2,13 +2,18 @@ SUMMARY = "Dasharo Tools Suite scripts."
 HOMEPAGE = "https://github.com/Dasharo/dts-scripts"
 SECTION = "tools"
 
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSES/Apache-2.0.txt;md5=c846ebb396f8b174b10ded4771514fcc"
 
 PV = "0.1+git${SRCPV}"
 
-SRC_URI = "git://github.com/Dasharo/dts-scripts;protocol=https;branch=main"
+SRC_URI = " \
+    git://github.com/Dasharo/dts-scripts;protocol=https;branch=main \
+    file://your-script.sh \
+    "
SRCREV = "895365d29902aaed17ed30cba1dd2944821f7218"
 
 S = "${WORKDIR}/git"
 
@@ -35,4 +40,9 @@ do_compile[noexec] = "1"
 
 do_install () {
     oe_runmake install DESTDIR="${D}"
+
+    install -d ${D}/script/destination/directory
+    install -m 755 ${WORKDIR}/your-script.sh ${D}/script/destination/directory
 }
+
+FILES:${PN}:append = " /script/destination/directory"
  1. Build DTS.

@DaniilKl
Copy link
Contributor

@wessel-novacustom check whether these guides will help you.

@m-iwanicki
Copy link

@DaniilKl mention that your way won't run a script during system start

@DaniilKl
Copy link
Contributor

mention that your way won't run a script during system start

I see I missed that part, yep, my guide only for adding script into FS, not for running it on start up.

@wessel-novacustom
Copy link

mention that your way won't run a script during system start

I see I missed that part, yep, my guide only for adding script into FS, not for running it on start up.

  • That's vital for us, though. Could you please implement such function and provide a test version?

@DaniilKl
Copy link
Contributor

DaniilKl commented Nov 20, 2024

@wessel-novacustom, I could do that. But I need some information:

  1. What the script will do?
  2. What are the dependencies for the script?
  3. At what moment you want to start your script?

@wessel-novacustom
Copy link

@wessel-novacustom, I could do that. But I need some information:

1. What the script will do?

2. What are the dependencies for the script?

3. At what moment you want to start your script?
  • After boot, right before the DTS menu opens.

I need to build DTS myself and it should check if autostart.sh in whatever folder is available. I should be able to include the autostart.sh in a folder that you specify. You can test it with something like echo Hello world! && pause 10 to check if it is working correctly.

In case it autostart.sh is available, it should execute that script. Otherwise, it should open the DTS main menu as usual.

I should fill the contents of autostart.sh myself as I would like to have that in my own control.

@DaniilKl
Copy link
Contributor

DaniilKl commented Nov 25, 2024

@wessel-novacustom, you cold do the following:

  1. Fork Dasharo/dts-scripts (this is the place where all DTS scripts are located now) and clone it.
  2. Do the following modification:
diff --git a/Makefile b/Makefile
index c11148ab0649..86c679de5eba 100644
--- a/Makefile
+++ b/Makefile
@@ -23,5 +23,7 @@ install:
        install -m 0755 reports/dasharo-hcl-report $(DESTDIR)$(SBINDIR)
        install -m 0755 reports/touchpad-info $(DESTDIR)$(SBINDIR)
 
+       install -m 0755 autostart.sh $(DESTDIR)$(SBINDIR)
+
        install -d $(DESTDIR)$(SYSCONFDIR)/profile.d
        install -m 0755 dts-profile.sh $(DESTDIR)$(SYSCONFDIR)/profile.d
diff --git a/scripts/dts-boot b/scripts/dts-boot
index b99d68df62f4..97d22ece86e1 100644
--- a/scripts/dts-boot
+++ b/scripts/dts-boot
@@ -25,5 +25,7 @@ source $DTS_HAL
 if [ -f $FUM_EFIVAR ]; then
     $SBIN_DIR/dasharo-deploy update fum
 else
+    [ -f "$SBIN_DIR/autostart.sh" ] && $SBIN_DIR/autostart.sh
+
     $BIN_DIR/script -c $SBIN_DIR/dts "$DTS_LOG_FILE"
 fi
  1. Add your autostart.sh into the cloned dts-scripts repo root.
  2. Commit and push the changes to your fork.
  3. Change dts-scripts_git.bb in meta-dts to point to your fork and your changes:
diff --git a/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb b/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
index 6d92efeab0b2..cb3211d00fa6 100644
--- a/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
+++ b/meta-dts-distro/recipes-dts/dts-scripts/dts-scripts_git.bb
@@ -7,8 +7,8 @@ LIC_FILES_CHKSUM = "file://LICENSES/Apache-2.0.txt;md5=c846ebb396f8b174b10ded477
 
 PV = "0.1+git${SRCPV}"
 
-SRC_URI = "git://github.com/Dasharo/dts-scripts;protocol=https;branch=main"
-SRCREV = "e757053cae37453cbd7dfaebf0f1a1676829fb25"
+SRC_URI = "git://your/fork/url;protocol=PROTOCOL;branch=BRANCH"
+SRCREV = "COMMIT"
 
 S = "${WORKDIR}/git"

Where: PROTOCOL is either http or ssh, BRANCH is the branch you pushed your changes to, COMMIT is a hash of the commit that contains your changes.

  1. Build:
kas-container build meta-dts/kas.yml

Note, if you used ssh protocol in the recipe, you should provide your keys to build, e. g.:

kas-container --ssh-dir ~/.ssh build meta-dts/kas.yml

@wessel-novacustom
Copy link

@DaniilKl Thank you so much! I will try in January and let you know if it worked.

@wessel-novacustom
Copy link

@DaniilKl The script is correctly executed at the background, thank you.

I'm working around that the scripts runs at the background by using:

broadcast_to_tty() {
    local message="$1"
    echo "$message" > /dev/pts/0 || echo "$message" > /dev/tty1
}

That works, but another problem is that the V540TU doesn't have internet access with the latest DTS version, even if the original DTS version is booted. This wasn't a problem when using v2.0.0-rc3 ... I hope this can be fixed soon :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DasharoToolsSuite documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants