wmdeit-cf-wmdelib/gitea.cf

102 lines
1.7 KiB
CFEngine3
Raw Normal View History

2023-11-13 12:50:25 +00:00
#
#
#
bundle agent gitea
{
vars:
debian::
"pkgs" slist => {
"daemon","git"
};
"user_home_dir" string => "/home/git";
centos::
"pkgs" slist => {
"daemonize","git"
};
"user_home_dir" string => "/home/git";
freebsd::
"pkgs" slist => {"gitea"};
"user_home_dir" string => "/usr/home/git";
any::
"user" string => "git";
}
body perms m_rxdirs( mode, rxdirs )
{
mode => "$(mode)";
rxdirs => "$(rxdirs)";
}
bundle agent install_gitea(cfg_param)
{
vars:
"default_cfg" data => '{
"version":"1.20.5",
"install_dir":"/var/gitea",
"work_dir":"/var/gitea/data",
}';
"cfg" data => mergedata(@(default_cfg),@(cfg_param));
"dlsrc" string => "https://dl.gitea.io/gitea/$(cfg[version])/gitea-$(cfg[version])-linux-amd64";
"gitea_exe" string => "$(cfg[install_dir])/gitea";
"app_ini" string => "$(work_dir)/app_ini";
methods:
"any" usebundle => wmde_install_packages(@(gitea.pkgs),"gitea");
!freebsd::
"any" usebundle => download_file("wget","$(dlsrc)","$(gitea_exe)","gitea", '{ "m":"755" }');
files:
"$(cfg[install_dir])/."
create => "true",
handle => "gitea_work_dir_created",
perms => mo("755","$(gitea.user)");
"$(gitea.user_home_dir)/."
create => "true",
perms => mo("755","$(gitea.user)");
# freebsd::
# "/home"
# link_from => ln_s("/usr/home"),
# move_obstructions => "true";
users:
"$(gitea.user)"
policy => "present",
home_dir => "$(gitea.user_home_dir)",
#group_primary => "users",
shell => "/bin/sh",
handle => "gitea_user_created";
processes:
"gitea"
restart_class => "start_gitea";
methods:
(!freebsd)&start_gitea::
"any" usebundle => daemonize(
"/usr/bin/su git -c '$(gitea_exe) --config /var/gitea/app.ini'"
),
classes => if_ok("gitea_ok_start");
reports:
}