summarylogtreecommitdiffstats
path: root/mx-samba-config.install
blob: 8e38b02a66c00d4020011c404c9c8ab216069d89 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Colored makepkg-like functions
msg_blue() {
  printf "${BLUE}==>${BOLD} $1${ALL_OFF}\n"
}

note1() {
  printf "${BLUE}==>${YELLOW} NOTE:${BOLD} $1${ALL_OFF}\n"
}

note2() {
  printf "${BLUE}==>      ${BOLD} $1${ALL_OFF}\n"
}

ALL_OFF="$(tput sgr0)"
BOLD="${ALL_OFF}$(tput bold)"
BLACK="${BOLD}$(tput setaf 0)"
RED="${BOLD}$(tput setaf 1)"
GREEN="${BOLD}$(tput setaf 2)"
YELLOW="${BOLD}$(tput setaf 3)"
BLUE="${BOLD}$(tput setaf 4)"
MAGENTA="${BOLD}$(tput setaf 5)"
CYAN="${BOLD}$(tput setaf 6)"
WHITE="${BOLD}$(tput setaf 7)"

post_install() {
  systemctl is-active smb >/dev/null || systemctl enable smb
  systemctl is-active nmb >/dev/null || systemctl enable nmb
  systemctl is-active avahi-daemon >/dev/null || systemctl enable avahi-daemon

  chgrp -R sambashare var/lib/samba/usershares

  echo
  note1 "The group 'sambashare' has been created,"
  note2 "and is the group owner of the folder:"
  note2 "    /var/lib/samba/usershares"
  note2
  note1 "To add users to 'sambashare':"
  note2 "    usermod -a -G sambashare [username]"
  echo
}

post_remove() {
  ! systemctl is-enabled smb >/dev/null || systemctl disable smb
  ! systemctl is-enabled nmb >/dev/null || systemctl disable nmb

  if [ -e var/lib/samba/usershares ] ; then
    chgrp -R root var/lib/samba/usershares
  fi

  echo
  note1 "The group 'sambashare' was created on install."
  note2 "Do not forget to check file ownership"
  note2 "before removing the group with the command:"
  note2 "    groupdel sambashare"
  note2
  note1 "The following folder was created on install."
  note2 "    /var/lib/samba/usershares"
  note2 "Do not forget to check content ownership"
  note2 "before removing the folder."
  echo
}

post_upgrade() {
  post_install
}