summarylogtreecommitdiffstats
path: root/tfenv.install
blob: 370814cc8809d0c607c787086e4af17eae2ca057 (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/tfenv/versions" ]; then
                echo "Detected old tfenv paths. Moving..."
                mv /usr/local/lib/tfenv/version{,s} /var/lib/tfenv/
		rm -r /usr/local/lib/tfenv
        fi
	common
}

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