1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +01:00

Update box_setup.zsh to use functions and include the Yarn package manager

This commit is contained in:
David O' Rojo 2019-08-30 11:43:05 -05:00
parent ae9133b1c5
commit fa23079199
2 changed files with 138 additions and 121 deletions

View File

@ -2,7 +2,7 @@
FabManager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects. FabManager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.
[![Coverage Status](https://coveralls.io/repos/github/sleede/fab-manager/badge.svg)](https://coveralls.io/github/sleede/fab-manager) [![Coverage Status](https://coveralls.io/repos/github/sleede/fab-manager/badge.svg)](https://coveralls.io/github/sleede/fab-manager)
[![Docker pulls](https://img.shields.io/docker/pulls/sleede/fab-manager.svg)](https://hub.docker.com/r/sleede/fab-manager/) [![Docker pulls](https://img.shields.io/docker/pulls/sleede/fab-manager.svg)](https://hub.docker.com/r/sleede/fab-manager/)
[![Docker Build Status](https://img.shields.io/docker/build/sleede/fab-manager.svg)](https://hub.docker.com/r/sleede/fab-manager/builds) [![Docker Build Status](https://img.shields.io/docker/build/sleede/fab-manager.svg)](https://hub.docker.com/r/sleede/fab-manager/builds)
@ -69,13 +69,13 @@ This procedure is not easy to follow so if you don't need to write some code for
1. Install RVM, with the ruby version specified in the [.ruby-version file](.ruby-version). 1. Install RVM, with the ruby version specified in the [.ruby-version file](.ruby-version).
For more details about the process, please read the [official RVM documentation](http://rvm.io/rvm/install). For more details about the process, please read the [official RVM documentation](http://rvm.io/rvm/install).
If you're using ArchLinux, you may have to [read this](doc/archlinux_readme.md) before. If you're using ArchLinux, you may have to [read this](doc/archlinux_readme.md) before.
2. Install NVM, with the node.js version specified in the [.nvmrc file](.nvmrc). 2. Install NVM, with the node.js version specified in the [.nvmrc file](.nvmrc).
For instructions about installing NVM, please refer to [the NVM readme](https://github.com/creationix/nvm#installation). For instructions about installing NVM, please refer to [the NVM readme](https://github.com/creationix/nvm#installation).
3. Install Yarn, the front-end package manager. 3. Install Yarn, the front-end package manager.
Depending on your system, the installation process may differ, please read the [official Yarn documentation](https://yarnpkg.com/en/docs/install#debian-stable). Depending on your system, the installation process may differ, please read the [official Yarn documentation](https://yarnpkg.com/en/docs/install#debian-stable).
4. Install docker. 4. Install docker.
Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated. Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated.
Please refer to [ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [debian](https://docs.docker.com/install/linux/docker-ce/debian/) or [MacOS](https://docs.docker.com/docker-for-mac/install/) documentation to setup a recent version of docker. Please refer to [ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [debian](https://docs.docker.com/install/linux/docker-ce/debian/) or [MacOS](https://docs.docker.com/docker-for-mac/install/) documentation to setup a recent version of docker.
@ -94,7 +94,7 @@ This procedure is not easy to follow so if you don't need to write some code for
You may have to change the network address if it is already in use. You may have to change the network address if it is already in use.
```bash ```bash
docker network create --subnet=172.18.0.0/16 fabmanager docker network create --subnet=172.18.0.0/16 fabmanager
``` ```
7. Retrieve the project from Git 7. Retrieve the project from Git
@ -154,7 +154,7 @@ This procedure is not easy to follow so if you don't need to write some code for
13. Build the databases. 13. Build the databases.
- **Warning**: **DO NOT** run `rake db:setup` instead of these commands, as this will not run some required raw SQL instructions. - **Warning**: **DO NOT** run `rake db:setup` instead of these commands, as this will not run some required raw SQL instructions.
- **Please note**: Your password length must be between 8 and 128 characters, otherwise db:seed will be rejected. This is configured in [config/initializers/devise.rb](config/initializers/devise.rb) - **Please note**: Your password length must be between 8 and 128 characters, otherwise db:seed will be rejected. This is configured in [config/initializers/devise.rb](config/initializers/devise.rb)
```bash ```bash
# for dev # for dev
@ -229,6 +229,7 @@ environment.
```bash ```bash
cd /vagrant cd /vagrant
bundle install bundle install
yarn install
``` ```
7. Set a directory for Sidekick pids: 7. Set a directory for Sidekick pids:
@ -310,7 +311,7 @@ In FabManager, it is used for the admin's statistics module and to perform searc
mkdir -p .docker/elasticsearch/plugins mkdir -p .docker/elasticsearch/plugins
mkdir -p .docker/elasticsearch/backups mkdir -p .docker/elasticsearch/backups
``` ```
2. Copy the default configuration files 2. Copy the default configuration files
```bash ```bash
cp docker/elasticsearch.yml .docker/elasticsearch/config cp docker/elasticsearch.yml .docker/elasticsearch/config
@ -396,8 +397,8 @@ In each cases, some inline comments are included in the localisation files.
They can be recognized as they start with the sharp character (#). They can be recognized as they start with the sharp character (#).
These comments are not required to be translated, they are intended to help the translator to have some context information about the sentence to translate. These comments are not required to be translated, they are intended to help the translator to have some context information about the sentence to translate.
You will also need to translate the invoice watermark, located in `app/pdfs/data/`. You will also need to translate the invoice watermark, located in `app/pdfs/data/`.
You'll find there the [GIMP source of the image](app/pdfs/data/watermark.xcf), which is using [Rubik Mono One](https://fonts.google.com/specimen/Rubik+Mono+One) as font. You'll find there the [GIMP source of the image](app/pdfs/data/watermark.xcf), which is using [Rubik Mono One](https://fonts.google.com/specimen/Rubik+Mono+One) as font.
Use it to generate a similar localised PNG image which keep the default image size, as PDF are not responsive. Use it to generate a similar localised PNG image which keep the default image size, as PDF are not responsive.

View File

@ -1,127 +1,101 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Set environmen values ####################################################### ###
# Set user configuration
set_user_config() {
echo "Setting ´vagrant´ user profile configuration"
# Virtual environment flag # Virtual environment flag
echo '# Set virtual environment flag' >> ~/.profile echo -e '\n\n# Set virtual environment flag' >> ~/.profile
echo 'export VIRTUAL_DEV_ENV=true' >> ~/.profile echo -e 'export VIRTUAL_DEV_ENV=true\n' >> ~/.profile
echo "\n" >> ~/.profile
# Language configuration # Language configuration
echo '# Set locale configuration' >> ~/.profile echo -e '\n# Set locale configuration' >> ~/.profile
echo 'export LC_ALL=en_US.UTF-8' >> ~/.profile echo 'export LC_ALL=en_US.UTF-8' >> ~/.profile
echo 'export LANG=en_US.UTF-8' >> ~/.profile echo 'export LANG=en_US.UTF-8' >> ~/.profile
echo 'export LANGUAGE=en_US.UTF-8' >> ~/.profile echo -e 'export LANGUAGE=en_US.UTF-8\n' >> ~/.profile
echo "\n" >> ~/.profile }
# Install and setup PostgreSQL ################################################ ###
# Install and configure PostgreSQL database manager
echo "***************************************************" install_postgres() {
echo "Checking Postgres installation..."
echo "***************************************************"
if ! dpkg -s postgresql; then
echo "Installing PostgreSQL" echo "Installing PostgreSQL"
sudo apt update sudo apt-get update
sudo apt install -y postgresql postgresql-contrib sudo apt-get install -y postgresql postgresql-contrib
echo "Setting up user" # Set up ubuntu user
sudo -u postgres bash -c "psql -c \"CREATE USER ubuntu WITH PASSWORD 'ubuntu';\"" sudo -u postgres bash -c "psql -c \"CREATE USER ubuntu WITH PASSWORD 'ubuntu';\""
sudo -u postgres bash -c "psql -c \"ALTER USER ubuntu WITH SUPERUSER;\"" sudo -u postgres bash -c "psql -c \"ALTER USER ubuntu WITH SUPERUSER;\""
echo "Setting up extensions to all schemas" # Make available useful extensions to the schemas
sudo -u postgres bash -c "psql -c \"CREATE EXTENSION unaccent SCHEMA pg_catalog;\"" sudo -u postgres bash -c "psql -c \"CREATE EXTENSION unaccent SCHEMA pg_catalog;\""
sudo -u postgres bash -c "psql -c \"CREATE EXTENSION pg_trgm SCHEMA pg_catalog;\"" sudo -u postgres bash -c "psql -c \"CREATE EXTENSION pg_trgm SCHEMA pg_catalog;\""
fi
echo "***************************************************" # Start service
echo " Starting Postgres server " sudo service postgresql start
echo "***************************************************" }
sudo service postgresql start
###
# Install Redis data store
install_redis() {
echo "Installing Redis"
sudo apt-get install -y redis-server
}
# Install Redis ############################################################### ###
# Install Imagemagick image manipulation utilities
install_imagemagick() {
echo "Installing Imagemagick"
sudo apt-get install -y imagemagick
}
echo "***************************************************" ###
echo "Checking Redis installation..." # Install ElasticSearch search engine
echo "***************************************************" install_elasticsearch() {
if ! dpkg -s redis-server; then echo "Installing Oracle Java 8 and ElasticSearch"
echo "Instalating Redis" sudo apt-get install -y openjdk-8-jre apt-transport-https
sudo apt install -y redis-server
fi
# Install Imagemagick #########################################################
echo "***************************************************"
echo "Checking Imagemagik installation..."
echo "***************************************************"
if ! dpkg -s imagemagick; then
sudo apt install -y imagemagick
else
echo 'OK'
fi
# Install Elastic Search ######################################################
echo "***************************************************"
echo "Checking ElasticSearch installation..."
echo "***************************************************"
if ! dpkg -s elasticsearch; then
sudo apt install -y openjdk-8-jre apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
sudo apt update && sudo apt install -y elasticsearch sudo apt-get update && sudo apt-get install -y elasticsearch
# This configuration limits ElasticSearch memory use inside the virtual machine # This configuration limits ElasticSearch memory use inside the virtual machine
sudo echo "node.master: true" >> /etc/elasticsearch/elasticsearch.yml sudo bash -c "echo 'node.master: true' >> /etc/elasticsearch/elasticsearch.yml"
sudo echo "node.data: false" >> /etc/elasticsearch/elasticsearch.yml
sudo sed -i 's/#bootstrap.memory_lock: true/bootstrap.memory_lock: true/g' /etc/elasticsearch/elasticsearch.yml sudo sed -i 's/#bootstrap.memory_lock: true/bootstrap.memory_lock: true/g' /etc/elasticsearch/elasticsearch.yml
sudo sed -i 's/#ES_JAVA_OPTS=/ES_JAVA_OPTS="-Xms256m -Xmx256m"/g' /etc/default/elasticsearch sudo sed -i 's/#ES_JAVA_OPTS=/ES_JAVA_OPTS="-Xms256m -Xmx256m"/g' /etc/default/elasticsearch
sudo /bin/systemctl daemon-reload sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service sudo /bin/systemctl enable elasticsearch.service
else }
echo 'OK'
fi
###
# Install Ngrok exposer ###################################################### # Install Ngrok secure tunnel manager
install_ngrok() {
echo "***************************************************" echo 'Installing Ngrok'
echo "Checking for Ngrok... " sudo apt-get install -y unzip
echo "***************************************************"
if ! ngrok; then
sudo apt install -y unzip
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
sudo unzip ngrok-stable-linux-amd64.zip -d /usr/local/bin sudo unzip ngrok-stable-linux-amd64.zip -d /usr/local/bin
rm -rf ngrok-stable-linux-amd64.zip rm -rf ngrok-stable-linux-amd64.zip
else }
echo "OK"
fi
###
# Install Node Version Manager
install_nvm() {
echo "Installing NVM"
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
# Install Node Version Manager ################################################ echo -e "\n# Node Version Manager" >> ~/.profile
echo "***************************************************"
echo "Checking for NVM... "
echo "***************************************************"
if [[ ! -x "$HOME/.nvm" ]]; then
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
echo '# Node Version Manager' >> ~/.profile
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.profile echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.profile
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.profile echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.profile
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.profile echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.profile
echo "\n" >> ~/.profile echo -e "\n" >> ~/.profile
echo 'autoload -U add-zsh-hook' >> ~/.profile echo 'autoload -U add-zsh-hook' >> ~/.profile
echo 'load-nvmrc() {' >> ~/.profile echo 'load-nvmrc() {' >> ~/.profile
echo ' local node_version="$(nvm version)"' >> ~/.profile echo ' local node_version="$(nvm version)"' >> ~/.profile
echo ' local nvmrc_path="$(nvm_find_nvmrc)"' >> ~/.profile echo ' local nvmrc_path="$(nvm_find_nvmrc)"' >> ~/.profile
echo "\n" >> ~/.profile echo -e "\n" >> ~/.profile
echo ' if [ -n "$nvmrc_path" ]; then' >> ~/.profile echo ' if [ -n "$nvmrc_path" ]; then' >> ~/.profile
echo ' local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")' >> ~/.profile echo ' local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")' >> ~/.profile
echo "\n" >> ~/.profile echo -e "\n" >> ~/.profile
echo ' if [ "$nvmrc_node_version" = "N/A" ]; then' >> ~/.profile echo ' if [ "$nvmrc_node_version" = "N/A" ]; then' >> ~/.profile
echo ' nvm install' >> ~/.profile echo ' nvm install' >> ~/.profile
echo ' elif [ "$nvmrc_node_version" != "$node_version" ]; then' >> ~/.profile echo ' elif [ "$nvmrc_node_version" != "$node_version" ]; then' >> ~/.profile
@ -133,55 +107,97 @@ if [[ ! -x "$HOME/.nvm" ]]; then
echo ' fi' >> ~/.profile echo ' fi' >> ~/.profile
echo '}' >> ~/.profile echo '}' >> ~/.profile
echo 'add-zsh-hook chpwd load-nvmrc' >> ~/.profile echo 'add-zsh-hook chpwd load-nvmrc' >> ~/.profile
echo 'load-nvmrc' >> ~/.profile echo -e "load-nvmrc\n" >> ~/.profile
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
else }
echo "OK"
fi
###
# Install Node.js ############################################################# # Install stable version of Node.js
install_nodejs() {
echo "***************************************************" echo 'Installing Node.js'
echo "Checking for Node.js... "
echo "***************************************************"
if ! node --version; then
nvm install stable nvm install stable
nvm alias default stable nvm alias default stable
nvm use default nvm use default
else }
echo 'OK'
fi
###
# Install Yarn package manager
install_yarn() {
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get -y install yarn
}
# Ruby and Version Manager #################################################### ###
# Install Ruby Version Manager
echo "***************************************************" install_rvm() {
echo 'Cheking for Ruby... ' echo 'Installing RVM'
echo "***************************************************"
if ! ruby -v; then
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
sudo apt install -y libxml2 libxml2-dev libxslt1-dev libpq-dev
\curl -sSL https://get.rvm.io | bash \curl -sSL https://get.rvm.io | bash
source /home/vagrant/.rvm/scripts/rvm source $HOME/.rvm/scripts/rvm
rvm get head rvm get head
}
###
# Install Matz Ruby Interpreter
install_ruby() {
echo 'Installing Ruby'
sudo apt-get install -y libxml2-dev libxslt1-dev libpq-dev libidn11-dev
rvm install ruby-2.3.6 rvm install ruby-2.3.6
rvm use ruby-2.3.6@global rvm use ruby-2.3.6@global
gem update --system --no-ri --no-rdoc gem update --system --no-ri --no-rdoc
gem update --no-ri --no-rdoc gem update --no-ri --no-rdoc
rvm use ruby-2.3.6 --default rvm use ruby-2.3.6 --default
else rvm cleanup all
echo 'OK' }
fi
###
# Tune-up the system settings
system_tuning()
{
echo "Tunning up the system"
# Cleaning up ################################################################# sudo echo -e "\n## Redis tune-up" >> /etc/sysctl.conf
sudo echo '# Allow background save on low memory conditions' >> /etc/sysctl.conf
sudo echo -e "vm.overcommit_memory = 1\n" >> /etc/sysctl.conf
echo "***************************************************" sudo touch /etc/rc.local
echo 'Removing unused software... ' sudo echo '## Redis tune-up' >> /etc/rc.local
echo "***************************************************" sudo echo '# Reduce latency and memory usage' >> /etc/rc.local
rvm cleanup all sudo echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local
sudo apt autoremove sudo echo -e "\n\n"
sudo echo -e "exit 0\n" >> /etc/rc.local
sudo chmod +x /etc/rc.local
sudo echo -e "\n## ElasticSearch tune-up" >> /etc/sysctl.conf
sudo echo '# Increase max virtual memory areas' >> /etc/sysctl.conf
sudo echo -e "vm.max_map_count = 262144\n" >> /etc/sysctl.conf
}
###
# Remove unused software
clean_up() {
echo "Removing unused software"
sudo apt-get -y autoremove && sudo apt-get autoclean
}
setup() {
set_user_config
install_postgres
install_redis
install_imagemagick
install_elasticsearch
install_ngrok
install_nvm
install_nodejs
install_yarn
install_rvm
install_ruby
system_tunning
clean_up
}
setup "$@"