[WIP/notest] pixelfed sequence

This commit is contained in:
2019-05-12 01:07:33 +02:00
parent 310f7d5a1e
commit a1528de93e

128
seqs/pixelfed.sh Executable file
View File

@@ -0,0 +1,128 @@
#!/bin/bash
toolName="pixelfed"
toolDeps="jpegoptim"
toolPath="/var/www/pixelfed"
step_1_info() { echo "Updating apt"; }
step_1_alias() { ALIAS="install"; }
step_1() {
exe apt update
}
step_2_info() { echo -e "Installing $toolname dependencies: $toolDeps"; }
step_2() {
exe apt install $toolDeps -y
saveReturn $?
endReturn
}
step_3_info() { echo -e "Get $toolName using git"; }
step_3() {
exe git clone https://github.com/dansup/pixelfed $toolPath
exe cd $toolPath
exe composer install --no-dev
saveReturn $?
endReturn
}
step_4_info() { echo "Create mysql database for $toolName"; }
step_4() {
local mysqlDatabase
local mysqlUser
local mysqlPass
echo "Existing mysql databases:"
exe mysql -u root -e 'SHOW DATABASES;'
echo -en "Enter database name: "
read mysqlDatabase
endCheckEmpty mysqlDatabase "database name"
exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4;'
saveReturn $?
endReturn
echo "Existing mysql user:"
exe mysql -u root -e 'SELECT User, Host FROM mysql.user;'
echo -en "Enter mysql user name: "
read mysqlUser
endCheckEmpty mysqlDatabase "user name"
echo -en "Enter mysql user password: "
read mysqlPass
endCheckEmpty mysqlPass "password"
exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';'
saveReturn $?
endReturn
exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';'
saveReturn $?
endReturn
exe mysql -u root -e 'FLUSH PRIVILEGES;'
}
step_5_info() { echo "$toolName configuration"; }
step_5() {
exe cd $toolPath
exe cp .env.example .env
exe php artisan key:generate
exe php artisan storage:link
read -p "Edit database settings, hostname, etc... (Enter to continue)"
exe vi .env
exe php artisan migrate:fresh
}
step_6_info() { echo "Create admin user"; }
step_6() {
exe php artisan user:create
echo "Use \"php artisan user:admin 'username'\" to set admin"
}
step_7_info() { echo "Create pixelfed (horzion) service"; }
step_7() {
addConf "$horzionService" "$horzionServiceLoc"
exe systemctl daemon-reload
exe systemctl enable pixelfed.service
exe service pixelfed start
}
horizonServiceLoc="/etc/systemd/system/pixelfed.service"
horzionService="\
[Unit]
Description=Pixelfeds' Horizon
After=syslog.target
After=network.target
#Requires=mysql.service
Requires=mariadb.service
#Requires=postgresql.service
#Requires=memcached.service
#Requires=redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
RestartSec=2s
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/pixelfed/
ExecStart=/usr/bin/php /var/www/pixelfed/artisan horizon
Restart=always
Environment=
[Install]
WantedBy=multi-user.target"
# Sequence Revision
VERSION_SEQREV=2
# Workaround when called from different directory
# Not needed when path to sequencer is absolut
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
# Path to sequencer
. ${DIR}/../sequencer/sequencer.sh