Last active
March 27, 2020 02:37
-
-
Save haroldp/3702ea5885711f0f1a14cbf8d4136207 to your computer and use it in GitHub Desktop.
Install Huginn in a FreeBSD jail [WIP]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# following: | |
# https://github.com/huginn/huginn/blob/master/doc/manual/installation.md | |
JAIL_IP=10.0.0.42 | |
JAIL_NAME=huginn | |
ezjail-admin create -c zfs ${JAIL_NAME} ${JAIL_IP} | |
# just copy a resolve.conf from another jail | |
cp -p /usr/jails/mail/etc/resolv.conf /usr/jails/huginn/etc/ | |
ezjail-admin start huginn | |
ezjail-admin console huginn | |
ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime | |
pkg bootstrap | |
pkg install \ | |
runit \ | |
git \ | |
libyaml \ | |
gdbm \ | |
readline \ | |
ncurses \ | |
libffi \ | |
curl \ | |
libxml2 \ | |
libxslt \ | |
icu \ | |
logrotate \ | |
py27-docutils \ | |
pkgconf \ | |
cmake \ | |
node \ | |
graphviz \ | |
sudo \ | |
nginx \ | |
mysql57-client \ | |
bash \ | |
ruby \ | |
ruby26-gems \ | |
openssl \ | |
jq | |
gem install rake bundler foreman --no-document | |
gem update --system --no-document | |
gem install bundler:1.17.3 # dies without specifying the version | |
pkg install rubygem-nokogiri | |
pkg install v8 | |
pw groupadd huginn | |
echo 'CHANGEME' | pw useradd -n huginn \ | |
-g huginn \ | |
-m -s /usr/sbin/nologin \ | |
-c 'huginn webmaster' \ | |
-M 0755 \ | |
-h 0 | |
mysql> CREATE USER 'huginn'@'huginn' IDENTIFIED BY 'CHANGEME'; | |
mysql> SET default_storage_engine=INNODB; | |
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `huginn`.* TO 'huginn'@'huginn'; | |
cd /home/huginn | |
sudo -u huginn -H git clone https://github.com/huginn/huginn.git -b master huginn | |
cd /home/huginn/huginn | |
sudo -u huginn -H cp .env.example .env | |
sudo -u huginn mkdir -p log tmp/pids tmp/sockets | |
sudo chown -R huginn log/ tmp/ | |
sudo chmod -R u+rwX,go-w log/ tmp/ | |
sudo chmod -R u+rwX,go-w log/ | |
sudo chmod -R u+rwX tmp/ | |
sudo -u huginn -H chmod o-rwx .env | |
sudo -u huginn -H cp config/unicorn.rb.example config/unicorn.rb | |
vi .env ####### HEADSUP! Set DB info and RAILS_ENV=production ####### | |
# ugly! | |
ln -s /usr/local/bin/python2.7 /usr/local/bin/python2 | |
vi Gemfile ### replace "gem mini_racer" with "gem rubyracer" to fix v8 issues | |
sudo -u huginn -H bundle install ## dies, "libv8 requires python 2 to be installed in order to build, but it is currently not available" | |
sudo -u huginn -H bundle exec rake db:create RAILS_ENV=production | |
sudo -u huginn -H bundle exec rake db:migrate RAILS_ENV=production | |
sudo -u huginn -H bundle exec rake db:seed RAILS_ENV=production SEED_USERNAME=admin SEED_PASSWORD=cece1814fube | |
sudo -u huginn -H bundle exec rake assets:precompile RAILS_ENV=production | |
sudo -u huginn -H vi Procfile # Edit the Procfile and choose one of the suggested versions for production | |
Comment out (disable) these two lines | |
web: bundle exec rails server -p ${PORT-3000} -b ${IP-0.0.0.0} | |
jobs: bundle exec rails runner bin/threaded.rb | |
Enable (remove the comment) from these lines or those | |
# web: bundle exec unicorn -c config/unicorn.rb | |
# jobs: bundle exec rails runner bin/threaded.rb | |
# ACK!! this installs shit in /etc/service/ | |
sudo bundle exec rake production:export | |
sudo cp deployment/logrotate/huginn /etc/logrotate.d/huginn | |
sudo cp deployment/nginx/huginn /usr/local/etc/nginx/sites-available/huginn | |
sudo ln -s /usr/local/etc/nginx/sites-available/huginn /usr/local/etc/nginx/sites-enabled/huginn | |
sudo editor /etc/nginx/sites-available/huginn # Change YOUR_SERVER_FQDN to the fully-qualified | |
# domain name of your host serving Huginn. | |
sudo rm /usr/local/etc/nginx/sites-enabled/default | |
sudo nginx -t | |
sudo service nginx restart | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment