diff --git a/update.sh b/update.sh --- a/update.sh +++ b/update.sh @@ -6,7 +6,7 @@ source src/README.md.sh for pkgbuild_path in knotserver knotserver-git; do - for src in src/common/*.sh; do + for src in src/knotserver-shared/*.sh; do source ${src} done for src in src/${pkgbuild_path}/*.sh; do diff --git a/src/common/install.sh b/src/common/install.sh deleted file mode 100644 --- a/src/common/install.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/bash -cat << EOF > ${pkgbuild_path}/knotserver.install -post_install() { - echo - echo knotserver installed, with repositories stored in: ${knotserver_repo_path:-/var/lib/tangled/repositories} - echo - echo Use \`systemctl edit knotserver.service\` to set \`KNOT_SERVER_OWNER\` to the DID of the knot owner, - echo and override \`KNOT_SERVER_HOSTNAME\` if 'hostname' does not return the FQDN echo of your knot. - echo - echo To enable git push over ssh for tangled repositories, run: - echo " ln -s /usr/lib/systemd/sshd_config.d/knotserver.conf /etc/ssh/sshd_config.d/30-knotserver.conf" - echo " usermod -s /usr/bin/bash -d ${knotserver_repo_path:-/var/lib/tangled/repositories} ${knotserver_user:-git}" - echo - echo and reload sshd - echo -} -EOF diff --git a/src/common/service.sh b/src/common/service.sh deleted file mode 100644 --- a/src/common/service.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/bash -cat << EOF > ${pkgbuild_path}/knotserver.service -[Unit] -Description=tangled knot server -After=network.target network-online.target -Wants=network-online.target -AssertPathExists=${knotserver_path:-/var/lib/tangled} -AssertPathExists=${knotserver_repo_path:-/var/lib/tangled/repositories} - -[Service] -Environment="KNOT_SERVER_HOSTNAME=%H" -Environment="KNOT_SERVER_LISTEN_ADDR=127.0.0.1:5555" -Environment="KNOT_REPO_SCAN_PATH=${knotserver_repo_path:-/var/lib/tangled/repositories}" -WorkingDirectory=${knotserver_path:-/var/lib/tangled} -ExecStart=/usr/bin/knot server -Restart=always -User=${knotserver_user:-git} -Group=${knotserver_group:-git} - -StandardOutput=journal -StandardError=journal -LimitNOFILE=65536 - -# Creates /var/log/knotserver with the correct permissions for the repoguard log. -LogsDirectory=knotserver - -[Install] -WantedBy=multi-user.target -EOF diff --git a/src/common/sshd.conf.sh b/src/common/sshd.conf.sh deleted file mode 100644 --- a/src/common/sshd.conf.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/bash -cat << EOF > ${pkgbuild_path}/knotserver-sshd.conf -Match User ${knotserver_user:-git} - AuthorizedKeysCommand /usr/bin/knot keys -output authorized-keys -git-dir ${knotserver_repo_path:-/var/lib/tangled/repositories} -log-path ${knotserver_log_directory:-/var/log/knotserver}/keyfetch.log - AuthorizedKeysCommandUser nobody -EOF diff --git a/src/common/tmpfiles.conf.sh b/src/common/tmpfiles.conf.sh deleted file mode 100644 --- a/src/common/tmpfiles.conf.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/bash -cat << EOF > ${pkgbuild_path}/knotserver-tmpfiles.conf -d /etc/tangled 700 root root -d ${knotserver_path:-/var/lib/tangled} 755 ${knotserver_user:-git} ${knotserver_group:-git} - -d ${knotserver_repo_path:-/var/lib/tangled/repositories} 755 ${knotserver_user:-git} ${knotserver_group:-git} - -EOF diff --git a/src/knotserver-shared/install.sh b/src/knotserver-shared/install.sh new file mode 100644 --- /dev/null +++ b/src/knotserver-shared/install.sh @@ -0,0 +1,17 @@ +#!/usr/bin/bash +cat << EOF > ${pkgbuild_path}/knotserver.install +post_install() { + echo + echo knotserver installed, with repositories stored in: ${knotserver_repo_path:-/var/lib/tangled/repositories} + echo + echo Use \`systemctl edit knotserver.service\` to set \`KNOT_SERVER_OWNER\` to the DID of the knot owner, + echo and override \`KNOT_SERVER_HOSTNAME\` if 'hostname' does not return the FQDN echo of your knot. + echo + echo To enable git push over ssh for tangled repositories, run: + echo " ln -s /usr/lib/systemd/sshd_config.d/knotserver.conf /etc/ssh/sshd_config.d/30-knotserver.conf" + echo " usermod -s /usr/bin/bash -d ${knotserver_repo_path:-/var/lib/tangled/repositories} ${knotserver_user:-git}" + echo + echo and reload sshd + echo +} +EOF diff --git a/src/knotserver-shared/service.sh b/src/knotserver-shared/service.sh new file mode 100644 --- /dev/null +++ b/src/knotserver-shared/service.sh @@ -0,0 +1,29 @@ +#!/usr/bin/bash +cat << EOF > ${pkgbuild_path}/knotserver.service +[Unit] +Description=tangled knot server +After=network.target network-online.target +Wants=network-online.target +AssertPathExists=${knotserver_path:-/var/lib/tangled} +AssertPathExists=${knotserver_repo_path:-/var/lib/tangled/repositories} + +[Service] +Environment="KNOT_SERVER_HOSTNAME=%H" +Environment="KNOT_SERVER_LISTEN_ADDR=127.0.0.1:5555" +Environment="KNOT_REPO_SCAN_PATH=${knotserver_repo_path:-/var/lib/tangled/repositories}" +WorkingDirectory=${knotserver_path:-/var/lib/tangled} +ExecStart=/usr/bin/knot server +Restart=always +User=${knotserver_user:-git} +Group=${knotserver_group:-git} + +StandardOutput=journal +StandardError=journal +LimitNOFILE=65536 + +# Creates /var/log/knotserver with the correct permissions for the repoguard log. +LogsDirectory=knotserver + +[Install] +WantedBy=multi-user.target +EOF diff --git a/src/knotserver-shared/sshd.conf.sh b/src/knotserver-shared/sshd.conf.sh new file mode 100644 --- /dev/null +++ b/src/knotserver-shared/sshd.conf.sh @@ -0,0 +1,6 @@ +#!/usr/bin/bash +cat << EOF > ${pkgbuild_path}/knotserver-sshd.conf +Match User ${knotserver_user:-git} + AuthorizedKeysCommand /usr/bin/knot keys -output authorized-keys -git-dir ${knotserver_repo_path:-/var/lib/tangled/repositories} -log-path ${knotserver_log_directory:-/var/log/knotserver}/keyfetch.log + AuthorizedKeysCommandUser nobody +EOF diff --git a/src/knotserver-shared/tmpfiles.conf.sh b/src/knotserver-shared/tmpfiles.conf.sh new file mode 100644 --- /dev/null +++ b/src/knotserver-shared/tmpfiles.conf.sh @@ -0,0 +1,6 @@ +#!/usr/bin/bash +cat << EOF > ${pkgbuild_path}/knotserver-tmpfiles.conf +d /etc/tangled 700 root root +d ${knotserver_path:-/var/lib/tangled} 755 ${knotserver_user:-git} ${knotserver_group:-git} - +d ${knotserver_repo_path:-/var/lib/tangled/repositories} 755 ${knotserver_user:-git} ${knotserver_group:-git} - +EOF