summaryrefslogtreecommitdiff
path: root/extra/amule/amule.install
blob: 397f68bf2afec1b5484b6a325e91f0657952bb74 (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
post_install() {
  post_upgrade
  passwd -l amule &>/dev/null

  # Generate a random password for amuled<->amuleweb communication
  ec_password=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1)
  encripted_ec_password=$(echo -n $ec_password | md5sum | cut -d ' ' -f 1)
  # Create a config file
  sudo -u amule mkdir -p /var/lib/amule/.aMule
  echo "[ExternalConnect]
AcceptExternalConnections=1
ECPassword=$encripted_ec_password" > /var/lib/amule/.aMule/amule.conf

  sudo -u amule /usr/bin/amuleweb --write-config --password=$ec_password --admin-pass=amule

  echo "A new password for extarnal configuration is generated: $ec_password"
  echo "Please follow https://wiki.archlinux.org/index.php/AMule how to setup"
  echo "external connection (e.g. using amule-gui tool)."
  echo "amuleweb can be started as 'systemctl start amuleweb'."
  echo "Password for amuleweb: amule"
}

post_upgrade() {
  # create user/group that the daemon will run as by default, do not delete this on uninstall, as it will own files
  getent group amule >/dev/null || groupadd amule
  getent passwd amule >/dev/null || useradd -c 'aMule Client' -g amule -b '/var/lib' -m -s /bin/false amule
}

post_remove(){
  /usr/bin/systemctl stop amuled.service amuleweb.service

  getent passwd amule >/dev/null && userdel amule
  getent group amule >/dev/null && groupdel amule
}