Page 1 of 1
snapd without systemd (rough draft - looks like the script is missing things)
Posted: Sat Nov 07, 2020 4:19 am
by s243a
I was doing some research on how on might be able to use snap packages on puppy. I found the following script to simulate (somewhat) the systemd function:
/usr/bin/systemctl
Code: Select all
#!/bin/bash
# First parameter should be start or stop
# Second parameter will be the name of a unit file
if [ $# -lt 2 ]
then
echo "usage: $0 start unit-file"
exit 0
fi
if [ $1 == "start" ]
then
what=$(grep What /etc/systemd/system/"$2" | cut -f 2 -d '=')
where=$(grep Where /etc/systemd/system/"$2" | cut -f 2 -d '=')
mkdir -p "$where"
mount $what $where
exit 0
fi
if [ $1 == "stop" ]
then
where=$(grep Where /etc/systemd/system/"$2" | cut -f 2 -d '=')
umount $where
exit 0
fi
https://forum.mxlinux.org/viewtopic.php ... pd#p435179
according to the thread on the Mx linux form it should work. I'll give it a try. Anyway the basic steps are first to install "snapd" form the package manager.
https://snapcraft.io/docs/installing-snapd
Enable the socket for snapd (assume the above script is installed in lieu of systmd):
Code: Select all
systemctl enable --now snapd.socket
https://snapcraft.io/docs/installing-snap-on-arch-linux
Then start this with the following command:
Then
and optionally
https://snapcraft.io/docs/installing-snap-store-app
Re: snapd without systemd (rough draft - looks like the script is missing things)
Posted: Sat Nov 07, 2020 4:35 am
by s243a
Before trying it, I see some issues:
The script replacement for The drop in replacement for systemctl doesn't define "What" and "Where"
Here is what is in snapd.service
Code: Select all
[Unit]
Description=Snappy daemon
Requires=snapd.socket
OnFailure=snapd.failure.service
# This is handled by snapd
# X-Snapd-Snap: do-not-start
[Service]
# Disabled because it breaks lxd
# (https://bugs.launchpad.net/snapd/+bug/1709536)
#Nice=-5
OOMScoreAdjust=-900
ExecStart=/usr/lib/snapd/snapd
EnvironmentFile=-/etc/environment
Restart=always
WatchdogSec=5m
Type=notify
SuccessExitStatus=42
RestartPreventExitStatus=42
KillMode=process
[Install]
WantedBy=multi-user.target
I see now "What" or "Where" in this file so maybe nothing needs to be mounted for this service. Still though we should start the service and we want to start it with the command:
/usr/lib/snapd/snapd
but first we have to create the socket (i.e. the require part). If the stocket isn't created then if you try to run the snap command you get an error like:
Code: Select all
error: cannot communicate with server: Post http://localhost/v2/snaps/core: dial unix /run/snapd.socket: connect: no such file or directory
I'm guessing it is an http servicer because of the "Post" command shown above in the error. Maybe we can start the server using busybox's httpd.
Re: snapd without systemd (rough draft - looks like the script is missing things)
Posted: Sat Nov 07, 2020 5:14 am
by s243a
s243a wrote: ↑Sat Nov 07, 2020 4:35 am
but first we have to create the socket (i.e. the require part). If the stocket isn't created then if you try to run the snap command you get an error like:
Code: Select all
error: cannot communicate with server: Post http://localhost/v2/snaps/core: dial unix /run/snapd.socket: connect: no such file or directory
I'm guessing it is an http servicer because of the "Post" command shown above in the error. Maybe we can start the server using busybox's httpd.
I realized this is a strange error. The "snaps" folder suggests the "snaps" directory:
https://snapcraft.io/docs/system-snap-directory
which usually is:
This is weird though because it is almost like the server expects a directory for a package to exist before the package is installed. However, this likely isn't the case since the server likely uses dynamic paths.
As I side note, I'm wondering if I can use ncat here:
Code: Select all
ncat --listen --keep-open -U /run/snapd.socket --exec /usr/lib/snapd/snapd http://localhost/v2 0666
https://man7.org/linux/man-pages/man1/ncat.1.html
https://nmap.org/ncat/guide/index.html
Note that I chose the url path as "http://localhost/v2" because of the following output:
Code: Select all
snap services
error: cannot communicate with server: Get http://localhost/v2/apps?select=service: dial unix /run/snapd.socket: connect: no such file or directory
Re: snapd without systemd (rough draft - looks like the script is missing things)
Posted: Sat Nov 07, 2020 7:19 am
by s243a
Two problems with my above netcat command. First you just specify a host name (e.g. localhost) rather than the whole uri (i.e. http://localhost/v2/). The other issue is that you can't specify both a local host and a unix domain socket. I tried to get around this as follows. First the command:
Code: Select all
ncat -U /run/snapd.socket -v --listen --keep-open --exec /usr/lib/snapd/snapd 0666
then in another window I try to connect the unix domain socket with a tcp socket using socat:
Code: Select all
socat TCP-LISTEN:0666,reuseaddr UNIX-CLIENT:/run/snapd.socket
https://serverfault.com/questions/51790 ... y-over-tcp
https://linux.die.net/man/1/socat
At first everything looks good and the output of my ncat command is:
Code: Select all
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on /run/snapd.socket
However, when I try to run a snap command, I get an error saying the socket is already in use:
Code: Select all
Ncat: Connection from a client on Unix domain socket.
Ncat: Connection from .
Ncat: error: when trying to listen on /run/snapd.socket: socket "/run/snapd.socket" already in use
Connection from a client on Unix domain socket.
Ncat: Connection from .
However, if I don't do the socat command then it will tell me that the socket doesn't exist.
Re: snapd without systemd (rough draft - looks like the script is missing things)
Posted: Sat Nov 07, 2020 7:39 am
by s243a
I found something that might be helpful (to research later):
Package: init-system-helpers (1.58) [essential]
helper tools for all init systems
This package contains helper tools that are necessary for switching between the various init systems that Debian contains (e. g. sysvinit or systemd). An example is deb-systemd-helper, a script that enables systemd unit files without depending on a running systemd.
It also includes the "service", "invoke-rc.d", and "update-rc.d" scripts which provide an abstraction for enabling, disabling, starting, and stopping services for all supported Debian init systems as specified by the policy.
While this package is maintained by pkg-systemd-maintainers, it is NOT specific to systemd at all. Maintainers of other init systems are welcome to include their helpers in this package.
https://packages.debian.org/sid/init-system-helpers
I found this by searching for "deputy init" which was mentioned here:
https://forum.snapcraft.io/t/installing ... emd/3949/5
https://lists.ubuntu.com/archives/trust ... 23179.html