Equivalent for Debian's /etc/rc.local

Ask questions about Arch Linux ARM. Please search before making a new topic.

Equivalent for Debian's /etc/rc.local

Postby ssn » Thu Jul 25, 2024 10:49 am

I'm setting up a Raspberry Pi 3 as a Tor relay with Arch Linux for ARM, as replacement for an older Raspberry with Raspbian.

To avoid writes to Flash memory, I've been working with read-only partitions and [code]tmpfs[/code] file systems for log files and some other data.

On Debian (Raspbian), [code]/etc/rc.local[/code] triggered a script after partitions were made available via [code]/etc/fstab[/code] but before regular services are started.

[code]/var/lib/tor[/code] is a [code]tmpfs[/code].
[code]/var/lib/tor/key[/code] is created as a mountpoint.
Then a small persistent filesystem is mapped to [code]/var/lib/tor/key[/code].

This script has to be executed after filesystems are mounted via [code]/etc/fstab[/code], but before the Tor daemon starts.

[b]What's the best way with Arch Linux to achieve the same behaviour?
[/b]

E.g. a systemd script, and making somehow sure that it runs before the Tor service is started?


Thanks!
ssn
 
Posts: 1
Joined: Thu Jul 25, 2024 10:42 am

Re: Equivalent for Debian's /etc/rc.local

Postby terrifiedpoor » Thu Sep 05, 2024 1:42 am

Create a systemd service on Arch Linux to run your script before Tor starts:

1. Write your script (`/usr/local/bin/setup-tor-mounts.sh`) to create and mount `tmpfs`.
2. Create `/etc/systemd/system/setup-tor-mounts.service`:

[Unit]
After=local-fs.target
Before=tor.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/setup-tor-mounts.sh

[Install]
WantedBy=multi-user.target


3. Run:

sudo systemctl daemon-reload
sudo systemctl enable setup-tor-mounts.service
```

This ensures the script runs before Tor.
terrifiedpoor
 
Posts: 1
Joined: Thu Sep 05, 2024 1:40 am


Return to User Questions

Who is online

Users browsing this forum: No registered users and 9 guests