summarylogtreecommitdiffstats
path: root/tofuenv.install
blob: 41430926735c16382f5e7b856fcc8042875c9768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
post_install () {
	common
}

post_upgrade() {
        if [ -d "/usr/local/lib/tofu/versions" ]; then
                echo "Detected old tofu paths. Moving..."
                mv /usr/local/lib/tofu/version{,s} /var/lib/tofu/
		rm -r /usr/local/lib/tofu
        fi
	common
}

common () {
	if ! getent group tofu >/dev/null ; then
		echo "Adding group 'tofu'"
		groupadd tofu
	fi
	mkdir -p "/var/lib/tofu/versions"
	touch "/var/lib/tofu/version"
	chgrp -R tofu "/var/lib/tofu/versions" "/var/lib/tofu/version"
	chmod -R 775 "/var/lib/tofu/versions" "/var/lib/tofu/version"
	echo '######################################'
	echo '# In order to be able to install and change tofu versions as a non-root user, please add it to the group tofu'
	echo '#   sudo usermod -aG tofu ${USER}'
	echo '######################################'
}