Run script as root without sudo

2021-08-18 Thread Aristedes Maniatis via freebsd-stable
I've got some scripts which are intended to run on a new EC2 instance right after it is created. Since the script needs to install packages it need to run as root. But because I don't have sudo installed at this point (it is a brand new instance), I've only got 'su' to get root. The script its

Re: Run script as root without sudo

2021-08-18 Thread Jonathan Chen
On Thu, 19 Aug 2021 at 17:33, Aristedes Maniatis via freebsd-stable wrote: [...] > How else can I get this script running as root remotely in a completely > unattended way? The way it's usually done is with an rc script in /usr/local/etc/rc.d, eg: /usr/local/etc/rc.d/myscript and add the entry

Re: Run script as root without sudo

2021-08-18 Thread Aristedes Maniatis via freebsd-stable
That would require root to put the file there and then to reboot the machine. Ari On 19/8/21 4:16pm, Jonathan Chen wrote: On Thu, 19 Aug 2021 at 17:33, Aristedes Maniatis via freebsd-stable wrote: [...] How else can I get this script running as root remotely in a completely unattended way?

Re: Run script as root without sudo

2021-08-18 Thread Jonathan Chen
On Thu, 19 Aug 2021 at 18:25, Aristedes Maniatis wrote: > > That would require root to put the file there and then to reboot the > machine. In which case, wouldn't it be simpler to just start a new instance, install your packages by hand, and then take a snapshot of the volume and convert it to a

Re: Run script as root without sudo

2021-08-18 Thread Matt Garber
> That would require root to put the file there and then to reboot the > machine. > > Ari As these are EC2 instances, you should be able to use user-data provided to the instance’s configinit (like cloud-init) with firstboot_pkgs_list=“sudo” similar to Colin’s example here[1], and then run your

Re: Run script as root without sudo

2021-08-18 Thread Walter Parker
On Wed, Aug 18, 2021 at 11:36 PM Jonathan Chen wrote: > On Thu, 19 Aug 2021 at 18:25, Aristedes Maniatis wrote: > > > > That would require root to put the file there and then to reboot the > > machine. > > In which case, wouldn't it be simpler to just start a new instance, > install your package