forked from danbooru/danbooru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTALL.debian
113 lines (88 loc) · 3.86 KB
/
INSTALL.debian
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Run: curl -s https://raw.githubusercontent.com/r888888888/danbooru/master/INSTALL.debian > install.sh ; chmod +x install.sh ; ./install.sh
if [[ "$(whoami)" != "root" ]] ; then
echo "You must run this script as root"
exit 1
fi
echo "* DANBOORU INSTALLATION SCRIPT"
echo "*"
echo "* This script will install all the necessary packages to run Danbooru on a "
echo "* Debian server."
echo
echo -n "* Enter the hostname for this server (ex: danbooru.donmai.us): "
read HOSTNAME
if [[ -z "$HOSTNAME" ]] ; then
echo "* Must enter a hostname"
exit 1
fi
RUBY_VERSION=1.9.3-p327
GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install
echo -n "* Enter a name for the site (default: Danbooru): "
read SITENAME
if [[ -z "$SITENAME" ]] ; then
SITENAME=Danbooru
fi
# Install packages
echo "* Installing packages..."
apt-get update
apt-get -y install build-essential automake libssl-dev libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcache-dev git curl libcurl4-openssl-dev imagemagick libmagickcore-dev libmagickwand-dev sendmail-bin sendmail postgresql postgresql-contrib libpq-dev nginx ssh
if [ $? -ne 0 ]; then
echo "* Error installing packages; aborting"
exit 1
fi
# Create user account
useradd -m danbooru
chsh -s /bin/bash danbooru
usermod -G danbooru,sudo danbooru
# Install rbenv
echo "* Installing rbenv..."
cd /
sudo -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv
sudo -u danbooru touch ~danbooru/.bash_profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~danbooru/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~danbooru/.bash_profile
sudo -u danbooru mkdir -p ~danbooru/.rbenv/plugins
sudo -u danbooru git clone git://github.com/sstephenson/ruby-build.git ~danbooru/.rbenv/plugins/ruby-build
sudo -u danbooru bash -l -c "rbenv install $RUBY_VERSION"
sudo -u danbooru bash -l -c "rbenv global $RUBY_VERSION"
# Generate secret token and secret key
echo "* Generating secret keys..."
sudo -u danbooru mkdir ~danbooru/.danbooru/
sudo -u danbooru openssl rand -hex 32 > ~danbooru/.danbooru/secret_token
sudo -u danbooru openssl rand -hex 32 > ~danbooru/.danbooru/session_secret_key
chmod 600 ~danbooru/.danbooru/*
# Install gems
echo "* Installing gems..."
sudo -u danbooru bash -l -c 'gem install --no-ri --no-rdoc bundler'
echo "* Install configuration scripts..."
# Update PostgreSQL
curl -L -s $GITHUB_INSTALL_SCRIPTS/postgresql_hba_conf -o /etc/postgresql/9.1/main/pg_hba.conf
/etc/init.d/postgresql restart
sudo -u postgres createuser -s danbooru
sudo -u danbooru createdb danbooru2
# Setup nginx
curl -L -s $GITHUB_INSTALL_SCRIPTS/nginx.danbooru.conf -o /etc/nginx/conf.d/danbooru.conf
sed -i -e "s/__hostname__/$HOSTNAME/g" /etc/nginx/conf.d/danbooru.conf
/etc/init.d/nginx restart
# Setup logrotate
curl -L -s $GITHUB_INSTALL_SCRIPTS/danbooru_logrotate_conf -o /etc/logrotate.d/danbooru.conf
# Setup danbooru account
echo "* Enter a new password for the danbooru account"
passwd danbooru
echo "* Setting up SSH keys for the danbooru account"
sudo -u danbooru ssh-keygen
echo "* Setting up danbooru app..."
sudo -u danbooru git clone https://github.com/r888888888/danbooru ~danbooru/danbooru
sudo -u danbooru bash -l -c 'cd ~/danbooru ; bundle'
echo "* Creating a new local git branch called develop"
sudo -u danbooru bash -l -c 'cd ~danbooru ; git checkout -b develop'
echo "* Setting up known_hosts for localhost"
ssh-keyscan -t rsa,dsa localhost 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts
cat ~/.ssh/tmp_hosts >> ~/.ssh/known_hosts
echo "* Almost done! The code has been checked out at ~danbooru/danbooru. You can "
echo "* now login as the danbooru user and run the following commands to deploy to "
echo "* the server:"
echo "*"
echo "* cd ~/danbooru"
echo "* bundle exec cap development deploy:setup"
echo "* bundle exec cap development deploy:update"