Skip to content

kaltsi/oneshot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oneshot
-------

Packages can have scripts installed into file system and they can request such
a script to be run at next boot by creating a link to /etc/oneshot.d/<uid>/

Links created to /etc/oneshot.d/0/ get run at the beginning of the next boot
as root. This happens before user session is started.

Links should be only created through the add-oneshot utility described in the
next section.

Links created to /etc/oneshot.d/default/ (or /etc/oneshot.d/1000/, which is a
link to default) get executed during next boot at the very beginning of the
user session and will be executed as normal user (nemo).

oneshot
-------

Executes the scripts found under /etc/oneshot.d/$UID/

Usage: oneshot [--mic]

The --mic option can be used for example when building images from
kickstart files with mic. Setting this option will export MIC_RUN,
which can be checked in the oneshot scriptlets.

add-oneshot
-----------

Adds a oneshot job to be run later or now.

Usage: add-oneshot [--now] [--user] <name of the job> [<more job names>]

If --now is given, job is run immediately instead of postponing it later
If instant run fails or if --now is not given, the link is created for later run
If --user is given, job is run as user, otherwise as root
Job name is given as name of the executable located in /usr/lib/oneshot.d ie.
no path mentioned


groupadd-user
-------------

Packages can create new groups and request that the default user (usually UID
1000, nemo) should be added to that group. They can do this by calling
/usr/bin/groupadd-user <groupname>, it will add the default user (looked up
from login.defs and passwd) to that group if possible.

During bootstrap this user might not exist yet, in that case the request is
saved, and will be executed through oneshot at the end of image creation, or
at the first device boot.


RPM packaging macros
--------------------

Oneshot scripts should be installed into %{_oneshotdir}

Packages using oneshot functionality must Require oneshot, and
Require(post) %{_oneshot_requires_post}

Packages using the groupadd functionality must Require oneshot,
Require(pre) %{_oneshot_groupadd_requires_pre} and  Require(post)
%{_oneshot_groupadd_requires_post}

Two convenience-macros are provided as well:

%_system_groupadd groupname adds a system group named groupname
%{_default_uid} contains the lowest UID reserved for users on the system

Example for adding a group for the default user in .spec file:
--------------------------------------------------------------

Requires(pre): %{_oneshot_groupadd_requires_pre}
Requires(post): %{_oneshot_groupadd_requires_post}
Requires: oneshot

%pre
%_system_groupadd groupname

%post
/usr/bin/groupadd-user groupname


Example for running a oneshot script in .spec file as user:
-----------------------------------------------------------

Requires(post): %{_oneshot_requires_post}
Requires: oneshot

%post
%{_bindir}/add-oneshot --user sample-script

(A file %{_oneshotdir}/sample-script needs to exist for this to work)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 92.4%
  • Prolog 7.6%