Skip to content

Instantly share code, notes, and snippets.

@yookoala
Last active April 17, 2020 03:10

Revisions

  1. yookoala revised this gist Apr 17, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions tick.spec
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ Release: %release
    License: MIT

    %description
    tick5 is a simple useless script that echos a message every 5 seconds.
    %{name} is a simple useless script that echos a message every %{sleep} seconds.


    %install
    @@ -25,7 +25,7 @@ tick5 is a simple useless script that echos a message every 5 seconds.
    %{__cat} <<EOF> %{buildroot}/usr/bin/%{name}
    #!/bin/bash

    # say something, with timestamp, every 5 seconds
    # say something, with timestamp, every %{sleep} seconds
    while echo "\$@"; do
    sleep %{sleep}s
    done
  2. yookoala revised this gist Apr 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion tick.spec
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@

    # Some metadata required by an RPM package
    Name: %name
    Summary: Print a message every 5s
    Summary: Print a message every %{sleep}s
    Version: %version
    Release: %release
    License: MIT
  3. yookoala renamed this gist Apr 16, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. yookoala revised this gist Apr 16, 2020. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions tick5.spec
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # Variables that can be override on build time.
    %{!?name: %define name tick5}
    %{!?sleep: %define sleep 5}
    %{!?name: %define name tick%{sleep}}
    %{!?version: %define version 0.0}
    %{!?release: %define release 1}
    %{!?systemdinstalldir: %define systemdinstalldir /etc/systemd/system}
    @@ -18,9 +19,18 @@ tick5 is a simple useless script that echos a message every 5 seconds.

    %install

    # copy the executable to buildroot.
    # create the executable from scratch in buildroot.
    %{__mkdir} -p %{buildroot}%{_prefix}/bin
    %{__cp} -pdf tick5 %{buildroot}%{_prefix}/bin/%{name}

    %{__cat} <<EOF> %{buildroot}/usr/bin/%{name}
    #!/bin/bash

    # say something, with timestamp, every 5 seconds
    while echo "\$@"; do
    sleep %{sleep}s
    done
    EOF

    %{__chmod} 755 %{buildroot}%{_prefix}/bin/%{name}

    # generate the systemd unit file to buildroot.
  5. yookoala created this gist Apr 16, 2020.
    46 changes: 46 additions & 0 deletions tick5.spec
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    # Variables that can be override on build time.
    %{!?name: %define name tick5}
    %{!?version: %define version 0.0}
    %{!?release: %define release 1}
    %{!?systemdinstalldir: %define systemdinstalldir /etc/systemd/system}
    %{!?message: %define message come on, James}

    # Some metadata required by an RPM package
    Name: %name
    Summary: Print a message every 5s
    Version: %version
    Release: %release
    License: MIT

    %description
    tick5 is a simple useless script that echos a message every 5 seconds.


    %install

    # copy the executable to buildroot.
    %{__mkdir} -p %{buildroot}%{_prefix}/bin
    %{__cp} -pdf tick5 %{buildroot}%{_prefix}/bin/%{name}
    %{__chmod} 755 %{buildroot}%{_prefix}/bin/%{name}

    # generate the systemd unit file to buildroot.
    %{__mkdir} -p %{buildroot}%{systemdinstalldir}
    %{__cat} <<EOF> %{buildroot}%{systemdinstalldir}/%{name}.service
    [Unit]

    [Install]
    WantedBy=multi-user.target

    [Service]
    ExecStart=%{_prefix}/bin/%{name} %{message}
    Restart=always
    RestartSec=5
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=%n
    EOF


    %files
    %{_prefix}/bin/%{name}
    %{systemdinstalldir}/%{name}.service