aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2024-06-10 17:16:35 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2024-06-10 18:32:07 +0200
commitad77b5101ab196c71bd7907d1c71084a06ac7b64 (patch)
tree4212afad419bec444b25ebd3deb07a52e5955b03
parente9c4d2e81382099decfad468bd89f67db55198d7 (diff)
downloadetc_apache2-ad77b5101ab196c71bd7907d1c71084a06ac7b64.tar.gz
etc_apache2-ad77b5101ab196c71bd7907d1c71084a06ac7b64.tar.bz2
etc_apache2-ad77b5101ab196c71bd7907d1c71084a06ac7b64.zip
Add script to restore permissions of git repositories.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--Makefile8
-rw-r--r--restore-permissions.sh47
-rwxr-xr-xsites-enabled/restore-permissions.sh42
3 files changed, 96 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 7a3451e..3ba7874 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,11 @@ apache2.tar.xz: apache2.tar
install -o root -g root -m 755 -d /etc/gitolite3
install -o root -g root -m 644 $^ $@
+/srv/git/git-data/repositories/restore-permissions.sh: restore-permissions.sh
+ install -o root -g root -m 755 -d /srv/git/git-data/
+ install -o git -g git -m 755 -d /srv/git/git-data/repositories
+ install -o git -g git -m 644 $^ $@
+
EXTRA_ETC_CONFIG = \
/etc/cgit.d/contrib.conf \
/etc/cgit.d/infrastructure.conf \
@@ -65,7 +70,8 @@ EXTRA_ETC_CONFIG = \
/etc/cgit.d/replicant.conf \
/etc/cgit.d/replicant-next.conf \
/etc/gitconfig \
- /etc/gitolite3/gitolite.rc
+ /etc/gitolite3/gitolite.rc \
+ /var/lib/gitolite3/repositories/restore-permissions.sh
update: $(EXTRA_ETC_CONFIG)
id www-data | grep 'groups=.*(git)' || gpasswd -a www-data git
diff --git a/restore-permissions.sh b/restore-permissions.sh
new file mode 100644
index 0000000..a237dea
--- /dev/null
+++ b/restore-permissions.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# Copyright (C) 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+set -e
+set -x
+
+# This file comes from the following repository and is being updated
+# along with the apache 2 configuration:
+# https://git.replicant.us/infrastructure/etc_apache2
+# So don't manually modify it.
+
+topdirs="contrib infrastructure mirrors replicant replicant-next"
+
+for topdir in ${topdirs} ; do
+ chown git:git -R "${topdir}"
+ chmod 755 "${topdir}"
+done
+
+for topdir in \
+ contrib/*/*.git \
+ contrib/GNUtoo/*/*.git \
+ contrib/wizzard/Android/*.git \
+ infrastructure/*.git \
+ mirrors/*/*.git \
+ replicant/*.git \
+ replicant-next/*.git ; do
+ # We at least have some symlinks.
+ if [ ! -L "${topdir}" ] ; then
+ chown git:git -R "${topdir}"
+ chmod 755 "${topdir}"
+ find "${topdir}" -type d | xargs chmod 755
+ find "${topdir}" -type f | xargs chmod 644
+ fi
+done
diff --git a/sites-enabled/restore-permissions.sh b/sites-enabled/restore-permissions.sh
new file mode 100755
index 0000000..8ab0777
--- /dev/null
+++ b/sites-enabled/restore-permissions.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Copyright (C) 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+set -e
+set -x
+
+topdirs="contrib infrastructure mirrors replicant replicant-next"
+
+for topdir in ${topdirs} ; do
+ chown git:git -R "${topdir}"
+ chmod 755 "${topdir}"
+done
+
+for topdir in \
+ contrib/*/*.git \
+ contrib/GNUtoo/*/*.git \
+ contrib/wizzard/Android/*.git \
+ infrastructure/*.git \
+ mirrors/*/*.git \
+ replicant/*.git \
+ replicant-next/*.git ; do
+ # We at least have some symlinks.
+ if [ ! -L "${topdir}" ] ; then
+ chown git:git -R "${topdir}"
+ chmod 755 "${topdir}"
+ find "${topdir}" -type d | xargs chmod 755
+ find "${topdir}" -type f | xargs chmod 644
+ fi
+done