| Server IP : 54.94.228.101 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/core18/current/usr/lib/core18/ |
Upload File : |
#!/bin/sh
#
# This script will try to find a suiteable snapd snap and start
# snapd and its associated services from it.
set -eux
# run_on_unseeded will mount/run snapd on an unseeded system
run_on_unseeded() {
SEED_SNAPD="$(find /var/lib/snapd/seed/snaps/ -name "snapd_*.snap")"
if [ ! -e "$SEED_SNAPD" ]; then
echo "Cannot find a seeded snapd"
ls /var/lib/snapd/seed/snaps
exit 1
fi
# mount snapd snap and run snapd directly, it will do
# the seeding and as part of this will restart snapd
# which will give it the right systemd unit.
TMPD=$(mktemp -d)
trap "umount -l $TMPD; rmdir $TMPD" EXIT
mount "$SEED_SNAPD" "$TMPD"
# We need to initialize /snap/snapd/current symlink so that the
# dynanic linker
# /snap/snapd/current/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
# is available to run snapd.
[ -d /snap/snapd ] || mkdir -p /snap/snapd
ln -sf "${TMPD}" /snap/snapd/current
# snapd will write all its needed snapd.{service,socket}
# units and restart once it seeded the snapd snap. We create
# a systemd socket unit so that systemd own the socket, otherwise
# the socket file would be removed by snapd on exit and the snapd.seeded
# service will fail because it has nothing to talk to anymore.
systemd-run --unit=snapd-seeding --service-type=notify --socket-property ListenStream=/run/snapd.socket --socket-property ListenStream=/run/snapd-snap.socket "$TMPD"/usr/lib/snapd/snapd
# we need to start the snapd service from above explicitly, systemd-run
# only enables the socket but does not start the service.
systemctl start --wait snapd-seeding.service
# at this point the snapd.socket is available
systemctl stop snapd-seeding.socket
# At this point snap is available and seeding is at the point where
# were snapd to installed and restarted successfully. Show progress
# now. Even without showing progress we *must* wait here until
# seeding is done to ensure that console-conf is only started
# after this script has finished.
# (redirect stdin because that is what snap checks for pty)
/usr/bin/snap watch --last=seed < /dev/console | tee -a /dev/console
}
# Unseeded systems need to be seeded first, this will start snapd
# and snapd will restart itself after the seeding.
set +e
# systemctl status returns exit code 4 for missing services, and 3 for disabled
# services
systemctl status snapd.service
snapdExists=$?
if [ ! -e /var/lib/snapd/state.json ] || [ $snapdExists = 4 ] ; then
set -e
if ! run_on_unseeded; then
echo "cannot run snapd from the seed"
exit 1
fi
exit 0
fi
set -e