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

[BUG] Boot sequence, IPFS before custom-cont-init.d #53

Closed
1 task done
hulkhaugen opened this issue Dec 16, 2023 · 1 comment
Closed
1 task done

[BUG] Boot sequence, IPFS before custom-cont-init.d #53

hulkhaugen opened this issue Dec 16, 2023 · 1 comment

Comments

@hulkhaugen
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm trying to add a custom script to this container, but I'm facing some challenges. I'm very limited in this field, but it seems to me that the script(s) in custom-cont-init.d are ran after some IPFS related stuff. The issue for me personally is that I want to remove /data and make a symlink from a variable, let's say /share/emulatorjs to /data. I'm doing this for a Home Assistant Add-on, so I'm somewhat limited from the usual approaches.

Maybe i'm approaching this wrong, I just want to be able to move the roms folders to /share.

Expected Behavior

Run script before anything else inside the container

Steps To Reproduce

  • Fresh install 1.7.3-ls75
  • Make a script that deletes /data, and adds a symlink from /share/emulatorjs to /data
  • Include the script in custom-cont-init.d
  • What the logs that says: cannot remove 'data': Resource busy

Environment

- OS: HassOS
- How docker service was installed: Plain, only added said script

CPU architecture

arm64

Docker creation

ARG BUILD_VERSION
FROM lscr.io/linuxserver/emulatorjs:$BUILD_VERSION
# Add custom script
COPY rootfs / 

********************
* custom-script.sh *
********************

#!/bin/sh

# Read the target folder from /data/options.json
# Default value is /share/emulatorjs
TARGET_FOLDER=$(jq -r '.rom_folder' /data/options.json)

# Ensure the target folder is owned by root
mkdir -p "$TARGET_FOLDER"
chown root:root "$TARGET_FOLDER"

# Create a symlink from /data to the specified target folder
rm -rf /data
ln -s "$TARGET_FOLDER" /data

# Debugging: Print the current state
ls -la /data/

Container logs

[custom-init] No custom services found, skipping...
[migrations] started
[migrations] no migrations found
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    0
User GID:    0
───────────────────────────────────────

generating ED25519 keypair...done
peer identity: 12D3KooWAEFs7wwHxD9PCRWTnwfi9KUbbqaQwNfpUpMHiMNXFFwK
initializing IPFS node at /data/.ipfs
to get started, enter:

	ipfs cat /ipfs/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc/readme

[custom-init] Files found, executing
[custom-init] 01-custom-data-folder.sh: executing...
rm: cannot remove '/data': Resource busy
total 8
drwxr-xr-x 2 root root 4096 Dec 16 20:33 .
drwxr-xr-x 1 root root 4096 Dec 16 20:33 ..
lrwxrwxrwx 1 root root   17 Dec 16 20:33 emulatorjs -> /share/emulatorjs
[custom-init] 01-custom-data-folder.sh: exited 0
Initializing daemon...
Kubo version: 0.19.2
Repo version: 13
System version: arm64/linux
Golang version: go1.20.11
@aptalca
Copy link
Member

aptalca commented Dec 16, 2023

If you want things to run before certain init scripts, then you'll have to inject proper s6 init steps. Take a look at this mod for instance, where it injects two separate init steps into different spots, one before package install and one after: https://github.com/linuxserver/docker-mods/tree/code-server-flutter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants