summaryrefslogtreecommitdiff
blob: 40aa75d90c331224e81343ef73a1b0fdfc1d4caa (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-irc/eggdrop/files/eggdrop-installer,v 1.8 2004/09/12 15:31:46 swegener Exp $

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() {
	einfo "Installing Eggdrop"
	einfo

	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: eggdrop-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() {
	bot_dir="${HOME}/.eggdrop/${bot_name}"

	if [ -d "${bot_dir}" ]
	then
		einfo "Already found a bot home directory for ${bot_name}"
		exit 1
	fi

	einfo "Creating directories for your ${bot_name}..."
	for dir in logs filesys/incoming text tmp scripts var
	do
		mkdir -p "${bot_dir}/${dir}"
	done

	einfo "Creating symlinks to required files for your bot to run..."
	for file in help language modules eggdrop
	do
		ln -s "/opt/eggdrop/${file}" "${bot_dir}/${file}"
	done

	einfo "Copying motd, banner, scripts and config file..."
	cp /opt/eggdrop/text/* "${bot_dir}/text"
	cp /opt/eggdrop/scripts/* "${bot_dir}/scripts"
	cp /opt/eggdrop/eggdrop.conf "${bot_dir}/eggdrop.conf"

	einfo "Finished..."
	einfo
	einfo "Please edit your ${bot_dir}/eggdrop.conf!"
	einfo
	einfo "The bot needs to be run from the ${bot_dir} directory."
	einfo "Run 'cd ${bot_dir} && ./eggdrop -m eggdrop.conf'"
	einfo "to create the user file and then remove the -m command line option"
	einfo "to start your eggdrop bot."
	einfo
	einfo "If you need any help pleaese refer to the man page, or"
	einfo "eggdrop website at http://www.egghelper.org/"
}

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