Skip to content

Instantly share code, notes, and snippets.

@shussekaido
Last active January 9, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shussekaido/ddd94060539ef90f7eaf to your computer and use it in GitHub Desktop.
Save shussekaido/ddd94060539ef90f7eaf to your computer and use it in GitHub Desktop.
Confluence 5 on FreeBSD 9 with OpenJDK 7
# 
#Prepare
# 
# On brand new FreeBSD do:
portsnap fetch extract
# Otherwise do:
portsnap fetch update
# 
# Change shell
# 
# Note that some commands below won't work in default CSH. Use either ZSH or /bin/sh.
# Install ZSH
cd /usr/ports/shells/zsh && make install clean
# this will change shell for current user
> chsh -s /usr/local/bin/zsh
export PACKAGESITE="ftp://ftp6.ru.freebsd.org/pub/FreeBSD/ports/`uname -m`/packages-9-current/Latest/"
pkg_add -r wget
pkg_add -r openjdk7
java -version
# openjdk version "1.7.0_06"
# OpenJDK Runtime Environment (build 1.7.0_06-b24)
# OpenJDK Client VM (build 23.2-b09, mixed mode)
# 
# Install Confluence
# 
mkdir /usr/local/confluence/ && cd /usr/local/confluence/
# Go to http://atlassian.com/software/confluence/download and check for latest version (Standalone, in either OS X or Linux section)
wget --no-check-certificate "http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-5.0.1.tar.gz" && mv atlas* confluence.tar.gz
tar zxvf confluence.tar.gz && rm confluence.tar.gz
ln -s /usr/local/confluence/atlassian-confluence-5.0.1/ /usr/local/confluence/current
mkdir confluence-home
echo 'confluence.home=/usr/local/confluence-home/' > /usr/local/confluence/current/confluence/WEB-INF/classes/confluence-init.properties
echo -e 'JAVA_HOME="/usr/local/openjdk7/"\nexport JAVA_HOME\n' >> /usr/local/confluence/current/bin/setenv.sh
pw add user confluence -d /usr/local/confluence-home -s /bin/sh -m
chown -R confluence:confluence /usr/local/confluence
# Start Confluence
sh /usr/local/confluence/current/bin/start-confluence.sh
# check log
tail -f /usr/local/confluence/current/logs/catalina.out
# 
Add Confluence to startup
# 
vi /usr/local/etc/rc.d/confluence.sh
# 
#!/bin/sh
# PROVIDE: confluence
# REQUIRE: postgresql
# BEFORE: LOGIN
# KEYWORD: shutdown
confluence_root="/usr/local/confluence/current"
JAVA_HOME="/usr/local/openjdk7/"
export JAVA_HOME
. /etc/rc.subr
name="confluence"
rcvar=${name}_enable
start_cmd="${name}_start"
stop_cmd=":"
load_rc_config $name
: ${confluence_enable:=no}
: ${confluence_msg="Starting Confluence."}
confluence_start()
{
${confluence_root}/bin/startup.sh start || err 1 "Error starting Confluence!"
}
load_rc_config $name
run_rc_command "$1"
# 
chmod +x /usr/local/etc/rc.d/confluence.sh
echo 'confluence_enable="YES"' >> /etc/rc.conf
# 
# Install PostgreSQL
# 
pkg_add -r postgresql92-server
echo 'postgresql_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/postgresql initdb
service postgresql start
# Create Confluence user and DB:
su pgsql
$ createuser -SDRP confuser
Enter password for new role: ******
Enter it again: ******
$ createdb confluence --owner=confuser --encoding=UTF-8 -e
# List databases and owners:
psql -l
$ exit
service postgresql restart
# 
# Forward port 80 to 8090
# 
# If you don't have a firewall enabled yet, let's enable PF
# The kernel will be recompiled with the firewall enabled
# If you don't have FreeBSD source, get it:
wget -P /usr/local/ ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -r`/src.txz && tar -C / -xvzf src.txz && rm /usr/local/src.txz
cp /usr/src/sys/`uname -m`/conf/GENERIC /usr/src/sys/`uname -m`/conf/PF
echo -e '\ndevice pf\ndevice pflog\ndevice pfsync\noptions ALTQ\noptions ALTQ_CBQ # Class Bases Queuing (CBQ)\noptions ALTQ_RED # Random Early Detection (RED)\noptions ALTQ_RIO # RED In/Out\noptions ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC)\noptions ALTQ_PRIQ # Priority Queuing (PRIQ)\noptions ALTQ_NOPCC # Required for SMP build/n' >> /usr/src/sys/`uname -m`/conf/PF
# To update the kernel faster or to build only custom modules, edit /etc/make.conf before starting to build the kernel:
echo 'MODULES_OVERRIDE = pf' >> /etc/make.conf
# This variable specifies the list of modules to build instead the default of building of all of them.
cd /usr/src && make buildkernel KERNCONF=PF
make installkernel KERNCONF=PF
echo -e '\npf_enable="YES"\npf_rules="/etc/pf.conf"\n' >> /etc/rc.conf
# Forward the port
echo 'rdr on em0 proto tcp from any to any port 80 -> 127.0.0.1 port 8090' >> /etc/pf.conf
# reboot
init 6
# You're done! Access your Confluence server hostname in the browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment