#!/bin/bash # Retrieve arguments domain=$1 path=$2 is_public=$3 port=$4 sudo yunohost app checkport $port if [[ ! $? -eq 0 ]]; then echo "Port $port is not available. Aborting..." exit 1 fi # Check domain/path availability sudo yunohost app checkurl $domain$path -a jenkins if [[ ! $? -eq 0 ]]; then exit 1 fi echo "Install dependencies..." wget -q -O - "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key" | sudo apt-key add - sudo bash -c "cat > /etc/apt/sources.list.d/jenkins.list << EOF deb http://pkg.jenkins-ci.org/debian binary/ EOF " sudo apt-get update sudo apt-get install jenkins -y if [[ "$path" != "/" ]]; then # $ means 'process only the last line' sudo sed -i '$ s@--ajp13Port=$AJP_PORT@--ajp13Port=$AJP_PORT --prefix=$PREFIX@g' /etc/default/jenkins fi sudo sed -i "/HTTP_PORT=.*/aHTTP_PORT=$port" /etc/default/jenkins sudo service jenkins restart sudo yunohost service add jenkins -l /var/log/jenkins/jenkins.log echo "Nginx configuration (sso disabled)..." sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf sed -i "s@YNH_PORT@$port@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/jenkins.conf sudo yunohost app setting jenkins is_public -v $is_public if [ "$is_public" = "Yes" ]; then sudo yunohost app setting jenkins unprotected_uris -v "/" fi sudo service nginx reload sudo yunohost app ssowatconf