summaryrefslogtreecommitdiff
blob: 73ac85c22b212c19bfdc47bcf153f7656bd08925 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

source /etc/init.d/functions.sh || {
  echo "$0: Could not source /etc/init.d/functions.sh!"
  exit 1
}

# Checks to see if user is trying to install eggdrop as root.
root_check() {

echo "Installing Eggdrop"
if [ "$HOME" = "/root" ] || [ `whoami` == "root" ];
then
   einfo "You should not be installing eggdrop as root."
   einfo ""
   einfo "Installing eggdrop as root leaves your computer vulnerable"
   einfo "to attack from other irc clients. Please use the eggdrop-installer"
   einfo "script as the user who you wish to run eggdrop with"
   exit 1
else
  install_eggdrop
fi

}

# Usage information
usage() {
cat << "USAGE_END"
Usage: eggbot-installer [bot-name]
Install eggdrop for a specific user, creating the directories and files
needed for eggdrop to run securely and safely.
USAGE_END

exit 1
}

install_eggdrop()
{
   if [ ! -d $HOME/.eggdrop ]
   then
       mkdir -p $HOME/.eggdrop
   fi
      einfo "Creating directories for your $bot_name ..."
      mkdir -p $HOME/.eggdrop/$bot_name 
      mkdir -p $HOME/.eggdrop/$bot_name/logs 
      mkdir -p $HOME/.eggdrop/$bot_name/filesys 
      mkdir -p $HOME/.eggdrop/$bot_name/filesys/incoming 
      mkdir -p $HOME/.eggdrop/$bot_name/text 
      mkdir -p $HOME/.eggdrop/$bot_name/scripts
      # Added because of bug #3073
      mkdir -p $HOME/.eggdrop/$bot_name/var
      

      einfo "Creating symlinks to required files for your bot to run ...."
      ln -s /opt/eggdrop/help $HOME/.eggdrop/$bot_name/help
      ln -s /opt/eggdrop/language $HOME/.eggdrop/$bot_name/language
      ln -s /opt/eggdrop/modules $HOME/.eggdrop/$bot_name/modules
      # Added because of bug #3073
      ln -s /opt/eggdrop/eggdrop $HOME/.eggdrop/$bot_name/eggdrop

      einfo "Copying motd and banner ... "
      cp /opt/eggdrop/text/* $HOME/.eggdrop/$bot_name/text

      # I changed this from a symlink to a direct copy because the user
      # might not have write permissions to /opt/eggdrop/scripts
      # as well as they might have their own custom scripts. - zul<chuck_short@rogers.com>
      cp /opt/eggdrop/scripts/* $HOME/.eggdrop/$bot_name/scripts

      einfo "Finished..."
      
      einfo "Please edit your $HOME/.eggdrop/$bot_name/eggdrop.conf "
      einfo "If you need any help pleaese refer to the man page, or "
      einfo "eggdrop website at http://www.egghelper.org"
      
      cp /opt/eggdrop/eggdrop.conf $HOME/.eggdrop/$bot_name/eggdrop.conf
}

if [ ! -n "$1" ]
then
  usage
else 
  bot_name="$1"
  root_check
fi