summarylogtreecommitdiffstats
path: root/sftpman.install
blob: bb8ee1f44ce4fe8898825076b976aa32e120afc9 (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
31
32
33
34
35
36
37
38
39
40
_ensure_mount_path() {
	mkdir -p -m 775 /mnt/sshfs
	chown :users /mnt/sshfs
}

post_install() {
	_ensure_mount_path

	# Let's see if everything is OK now..
	# This may not be very accurate, because it runs as root,
	# but it may still catch some potential problems.
	output=$(sftpman preflight_check 2>&1)
	if [ ! "$?" = "0" ]; then
		echo -e "sftpman preflight_check results:\n"
		echo "$output"
	fi
}

post_upgrade() {
	post_install $1

    if [[ "$2" =~ ^1:0\. ]]; then
		echo "======================"
		echo "NOTE: since sftpman=1.0, config files are stored as .json files, not as .js!";
		echo -e "\nYou must relocate your config files:";
		echo -e "\t"'for f in $(ls ~/.config/sftpman/mounts/*.js); do n=$(echo $f | sed 's/.js$/.json/'); mv $f $n; done;';
		echo "======================"
    fi
}

pre_remove() {
	echo "Unmounting any sftpman-mounted filesystems.."
	# The sleep.d script knows how to unmount sftpman filesystems for all users.
	# It's usually used during suspend/hibernate.
	/etc/pm/sleep.d/49-sftpman suspend
}

post_remove() {
	rmdir --ignore-fail-on-non-empty /mnt/sshfs
}