From d2f8492a987b4653febfb6f2d256b39ba1eaa7aa Mon Sep 17 00:00:00 2001 From: erdo_king Date: Thu, 17 Mar 2022 16:37:10 +0100 Subject: [PATCH 1/5] Fix version.sh get local version direct from binary --- files/version.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/files/version.sh b/files/version.sh index 92b28ed..02ad4db 100644 --- a/files/version.sh +++ b/files/version.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash - + set -e PUPPET_GOGS_INSTALLATION_DIRECTORY=$1 @@ -11,17 +11,10 @@ if [ ${PUPPET_GOGS_VERSION} == "latest" ]; then PUPPET_GOGS_VERSION=${LATEST_VERSION} fi -DOWNLOAD_VERSION_URL="https://raw.githubusercontent.com/gogits/gogs/v${PUPPET_GOGS_VERSION}/templates/.VERSION" - -if [ -f "${PUPPET_GOGS_INSTALLATION_DIRECTORY}/templates/.VERSION" ]; then +LOCAL_VERSION=$(${PUPPET_GOGS_INSTALLATION_DIRECTORY}/gogs --version 2>/dev/null| awk '{print $3}') - LOCAL_VERSION=$(<"${PUPPET_GOGS_INSTALLATION_DIRECTORY}/templates/.VERSION") - REMOTE_VERSION=$(wget -O- -q ${DOWNLOAD_VERSION_URL}) || exit 0 - - if [ ${LOCAL_VERSION} == ${REMOTE_VERSION} ]; then - exit 1 - fi - exit 0 +if [ ${LOCAL_VERSION} == ${PUPPET_GOGS_VERSION} ]; then + exit 1 +else + exit 0 fi - -exit 0 \ No newline at end of file From 257ef691ed427f18da7673caf42076b9384a63f5 Mon Sep 17 00:00:00 2001 From: erdo_king Date: Thu, 17 Mar 2022 16:38:59 +0100 Subject: [PATCH 2/5] Change git-package for Debian buster Package named "git" on Debian Buster not "git-core" --- manifests/packages.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/packages.pp b/manifests/packages.pp index b6c7b1b..093ca27 100644 --- a/manifests/packages.pp +++ b/manifests/packages.pp @@ -15,7 +15,7 @@ ensure_packages(['git', 'curl', 'wget', 'tar', 'initscripts']) } 'Debian': { - ensure_packages(['git-core', 'curl', 'wget', 'tar']) + ensure_packages(['git', 'curl', 'wget', 'tar']) } 'Ubuntu': { ensure_packages(['git-core', 'curl', 'wget', 'tar']) @@ -26,4 +26,4 @@ } } } -} \ No newline at end of file +} From 3ca7c598f716a59a0d8349180c3397dbe1e16332 Mon Sep 17 00:00:00 2001 From: erdo Date: Thu, 12 May 2022 23:54:07 +0200 Subject: [PATCH 3/5] gogs::sysconfig::debian - switched to systemd for debian --- manifests/sysconfig/debian.pp | 63 ++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/manifests/sysconfig/debian.pp b/manifests/sysconfig/debian.pp index 930d600..243ff4c 100644 --- a/manifests/sysconfig/debian.pp +++ b/manifests/sysconfig/debian.pp @@ -3,34 +3,57 @@ $service_name = $gogs::service_name, $installation_directory = $gogs::installation_directory, $owner = $gogs::owner, + $group = $gogs::group, ) { - # @see https://github.com/gogits/gogs/blob/master/scripts/init/centos/gogs - $sysconfig = { - 'NAME' => $service_name, - 'USER' => $owner, - 'WORKINGDIR' => $installation_directory, - 'DAEMON' => "${installation_directory}/${service_name}", - } - - file { "/etc/default/${service_name}": - ensure => 'file', - content => template('gogs/sysconfig.erb'), - owner => 'root', - group => 'root', - mode => '0755', - notify => Service[$service_name], - before => File["/etc/init.d/${service_name}"], - } - - file { "/etc/init.d/${service_name}": + file { "/etc/systemd/system/${service_name}.service": ensure => file, - source => "${installation_directory}/scripts/init/debian/gogs", + source => "${installation_directory}/scripts/systemd/gogs.service", owner => 'root', group => 'root', mode => '0755', + replace => false, + notify => Service[$service_name], + } ~> + exec { '/bin/systemctl daemon-reload': + refreshonly => true, notify => Service[$service_name], } + file_line { '${service_name}.service User': + ensure => present, + path => "/etc/systemd/system/${service_name}.service", + line => "User=${owner}", + match => "^User=", + notify => Exec['/bin/systemctl daemon-reload'], + } + file_line { '${service_name}.service Group': + ensure => present, + path => "/etc/systemd/system/${service_name}.service", + line => "Group=${group}", + match => "^Group=", + notify => Exec['/bin/systemctl daemon-reload'], + } + file_line { '${service_name}.service WorkingDirectory': + ensure => present, + path => "/etc/systemd/system/${service_name}.service", + line => "WorkingDirectory=${installation_directory}", + match => "^WorkingDirectory=", + notify => Exec['/bin/systemctl daemon-reload'], + } + file_line { '${service_name}.service ExecStart': + ensure => present, + path => "/etc/systemd/system/${service_name}.service", + line => "ExecStart=${installation_directory}/gogs web", + match => "^ExecStart=", + notify => Exec['/bin/systemctl daemon-reload'], + } + file_line { '${service_name}.service Environment': + ensure => present, + path => "/etc/systemd/system/${service_name}.service", + line => "Environment=USER=${owner} HOME=${installation_directory}", + match => "^Environment=", + notify => Exec['/bin/systemctl daemon-reload'], + } } From 88f01d550f65faad9a4ae613a7da8789de622c16 Mon Sep 17 00:00:00 2001 From: erdo Date: Fri, 13 May 2022 00:57:51 +0200 Subject: [PATCH 4/5] gogs::sysconfig::debian - fix mode for systemd file --- manifests/sysconfig/debian.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/sysconfig/debian.pp b/manifests/sysconfig/debian.pp index 243ff4c..b4bbe77 100644 --- a/manifests/sysconfig/debian.pp +++ b/manifests/sysconfig/debian.pp @@ -12,7 +12,7 @@ source => "${installation_directory}/scripts/systemd/gogs.service", owner => 'root', group => 'root', - mode => '0755', + mode => '0644', replace => false, notify => Service[$service_name], } ~> From fd85bf52024c76eed38e0d72e6a92681799b5fb1 Mon Sep 17 00:00:00 2001 From: erdo Date: Fri, 13 May 2022 09:55:42 +0200 Subject: [PATCH 5/5] gogs::sysconfig::debian - need to set home for ssh authentification --- manifests/sysconfig/debian.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/sysconfig/debian.pp b/manifests/sysconfig/debian.pp index b4bbe77..cdf2e5e 100644 --- a/manifests/sysconfig/debian.pp +++ b/manifests/sysconfig/debian.pp @@ -4,6 +4,7 @@ $installation_directory = $gogs::installation_directory, $owner = $gogs::owner, $group = $gogs::group, + $home = $gogs::home, ) { @@ -52,7 +53,7 @@ file_line { '${service_name}.service Environment': ensure => present, path => "/etc/systemd/system/${service_name}.service", - line => "Environment=USER=${owner} HOME=${installation_directory}", + line => "Environment=USER=${owner} HOME=${home}", match => "^Environment=", notify => Exec['/bin/systemctl daemon-reload'], }