summarylogtreecommitdiffstats
path: root/pkenv.install
blob: 936680203d1b7b4bd6ff959447d95e997ddc25c9 (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
29
30
post_install () {
	common
}

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

common () {
	if ! getent group pkenv >/dev/null ; then
		echo "Adding group 'pkenv'"
		groupadd pkenv
	fi

	mkdir -p "/var/lib/pkenv/versions"
	touch "/var/lib/pkenv/version"
	chgrp -R pkenv "/var/lib/pkenv/versions" "/var/lib/pkenv/version"
	chmod -R 775 "/var/lib/pkenv/versions" "/var/lib/pkenv/version"

	echo '######################################'
	echo '# In order to be able to install and change packer versions as a non-root user, please add it to the group pkenv'
	echo '# sudo usermod -aG pkenv ${USER}'
	echo '######################################'
}