Unverified Commit 53a9c565 authored by Erik Wilson's avatar Erik Wilson Committed by GitHub

Merge pull request #1548 from erikwilson/rpm-cleanup

Update RPM systemd services for easy modification.
parents 9a883715 d15eb6aa
......@@ -2,8 +2,8 @@
%define install_path /usr/bin
%define util_path %{_datadir}/k3s
%define install_sh %{util_path}/.install.sh
%define uninstall_sh %{util_path}/.uninstall.sh
%define install_sh %{util_path}/setup/install.sh
%define uninstall_sh %{util_path}/setup/uninstall.sh
Name: k3s
Version: %{k3s_version}
......@@ -23,26 +23,40 @@ The certified Kubernetes distribution built for IoT & Edge computing.
%install
install -d %{buildroot}%{install_path}
install dist/artifacts/%{k3s_binary} %{buildroot}%{install_path}/k3s
install -d %{buildroot}%{util_path}
install install.sh %{buildroot}%{install_sh}
install -d %{buildroot}%{util_path}/setup
install package/rpm/install.sh %{buildroot}%{install_sh}
%post
# do not run install script on upgrade
echo post-install args: $@
if [ $1 == 1 ]; then
INSTALL_K3S_BIN_DIR=%{install_path} \
INSTALL_K3S_SKIP_DOWNLOAD=true \
INSTALL_K3S_SKIP_ENABLE=true \
UNINSTALL_K3S_SH=%{uninstall_sh} \
# do not overwrite env file if present
export INSTALL_K3S_UPGRADE=true
export INSTALL_K3S_BIN_DIR=%{install_path}
export INSTALL_K3S_SKIP_DOWNLOAD=true
export INSTALL_K3S_SKIP_ENABLE=true
export INSTALL_K3S_DEBUG=true
export UNINSTALL_K3S_SH=%{uninstall_sh}
(
# install server service
INSTALL_K3S_NAME=server \
%{install_sh}
fi
%systemd_post k3s.service
# install agent service
INSTALL_K3S_SYMLINK=skip \
INSTALL_K3S_BIN_DIR_READ_ONLY=true \
K3S_TOKEN=example-token \
K3S_URL=https://example-k3s-server:6443/ \
%{install_sh} agent
# save debug log of the install
) >%{util_path}/setup/install.log 2>&1
%systemd_post k3s-server.service
%systemd_post k3s-agent.service
exit 0
%postun
echo post-uninstall args: $@
# do not run uninstall script on upgrade
if [ $1 == 0 ]; then
if [ $1 = 0 ]; then
%{uninstall_sh}
rm -rf %{util_path}
fi
......
cat <<EOF >/etc/yum.repos.d/rancher.repo
[rancher]
name=Rancher Repository
baseurl=https://rpm.rancher.io/
enabled=1
gpgcheck=1
gpgkey=https://rpm.rancher.io/public.key
EOF
......@@ -47,7 +47,7 @@ rpmbuild \
--define "_srcrpmdir ${PWD}" \
--define "_rpmdir ${PWD}/dist/rpm" \
--define "_buildrootdir ${PWD}/.rpm-build" \
-bb package/k3s.spec
-bb package/rpm/k3s.spec
if ! grep "BEGIN PGP PRIVATE KEY BLOCK" <<<"$PRIVATE_KEY"; then
echo "PRIVATE_KEY not defined, skipping rpm sign and upload"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment