Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id E76BB781A8B for <~alpine/users@lists.alpinelinux.org>; Tue, 28 Apr 2020 10:21:49 +0000 (UTC) X-Originating-IP: 81.14.30.15 Received: from [192.168.3.37] (15.30.14.81.rev.sfr.net [81.14.30.15]) (Authenticated sender: michel.piquemal@ipik.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 32C97E0007; Tue, 28 Apr 2020 10:21:46 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.5\)) Subject: Re: struggling with apk in unattended session From: spam@ipik.org In-Reply-To: <20200426002704.azrjjvoqhyhcsx4g@wolfsden.cz> Date: Tue, 28 Apr 2020 12:21:45 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <01E8F5A8-4851-47B0-97EE-DBECB9B8C779@ipik.org> References: <20200426002704.azrjjvoqhyhcsx4g@wolfsden.cz> To: ~alpine/users@lists.alpinelinux.org X-Mailer: Apple Mail (2.3445.9.5) I finally found it: there were 2 problems with same root cause. joe user is a no-login user, so I missed to make it part of wheel!... adduser joe wheel Then the second (nasty) bit is that PATH is not fully set for such user: while /bin/ and /usr/bin are in, /sbin is not! (where apk lies...) Therefore on need to run script with sh =E2=80=94login (or sh -l). Working snippet becomes: cat /usr/local/bin/update #!/bin/sh # do stuff1 here cd /tmp sh --login setup-mystuff > /tmp/update.log 2>&1 # fixed ! # do stuff2 here cat /tmp/setup-mystuff #!/bin/sh ! [ $(id -u) =3D 0 ] && { echo >&2 "Please run as root"; exit 1; } # do stuff3 here apk add # do stuff4 here sudo visudo -f /etc/sudoers.d/010_joe-nopasswd joe ALL=3D(root) NOPASSWD: /usr/local/bin/update