summarylogtreecommitdiffstats
path: root/amule-daemon.install
blob: 6e561e844617717f6a0afe4ca677b7b7059b7ce9 (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
66
67
all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
yellow="${bold}$(tput setaf 3)"
blue="${bold}$(tput setaf 4)"
green="${bold}$(tput setaf 2)"

_instructions() {
  printf "${yellow}==>${all_off} ${bold}ATENTION:${all_off}
  ${blue}->${all_off} If you plan to use external client (e.g. amuleGUI or amuleweb) then you need to
     provide ${bold}[ExternalConnect]${all_off} configuration.
  ${blue}->${all_off} You also need to specify amuleweb password.
     Please follow ${bold}https://wiki.archlinux.org/index.php/AMule${all_off} for more information.
  ${blue}->${all_off} Service '${bold}amule${all_off}' can be started as '${bold}systemctl start amule${all_off}'.
  ${blue}->${all_off} Service '${bold}amule@${all_off}' (by user) can be started as '${bold}systemctl start amule@${all_off}'
  ${blue}->${all_off} Service '${bold}amuleweb${all_off}' can be started as '${bold}systemctl start amuleweb${all_off}'.\n"
}

_notice_if_amuled_exist() {
  printf "${yellow}==>${all_off} ${bold}ATENTION:${all_off}
  ${green}==>${all_off} ${bold}Deprecated 'amuled' user/group found:${all_off}
  ${blue}->${all_off} The deprecated user/group '${bold}amuled${all_off}' has been removed.
  ${blue}->${all_off} New '${bold}amule${all_off}' user/group has been created instead.\n"
}

_instructions_if_amuled_exist() {
  printf "${yellow}==>${all_off} ${bold}ATENTION:${all_off}
  ${blue}->${all_off} The new aMule data path is ${bold}/var/lib/amule${all_off}
     Please move your Amule data to new path with:

     # ${bold}mv /var/lib/amuled/* /var/lib/amule${all_off}
     # ${bold}chown -R amule:amule /var/lib/amule${all_off}\n"
}

post_install() {
  post_upgrade $1
  _instructions
}

post_upgrade() {
  if id -u amuled >/dev/null 2>&1; then
    userdel amuled
    groupdel amuled
    _notice_if_amuled_exist
  fi
  if [ -d /var/lib/amuled ]; then
    _instructions_if_amuled_exist
  fi

  systemd-sysusers amule.conf

  install -dm744 -o amule -g amule /var/lib/amule
}

post_remove() {
  paths=(/var/lib/amule)

  first=true
  for path in ${paths[@]}; do
    if [ -d $path ]; then
      if $first; then
        first=false
        printf "${green}==>${all_off} ${bold}Leftover Paths:${all_off}\n"
      fi
      printf "${blue}  -> ${all_off} ${bold}$path${all_off}\n"
    fi
  done
}