Update with new sequencer features

This commit is contained in:
2019-12-09 23:40:15 +01:00
parent 07fcd28545
commit 982d34815f
3 changed files with 54 additions and 60 deletions

View File

@@ -2,7 +2,7 @@
toolName="pixelfed" toolName="pixelfed"
toolTag="dev" toolTag="dev"
toolDeps="composer jpegoptim php7.3-bcmath" toolDeps="composer jpegoptim php7.3-bcmath php-imagick"
toolPath="/var/www/pixelfed" toolPath="/var/www/pixelfed"
step_1_info() { echo "Updating apt"; } step_1_info() { echo "Updating apt"; }
@@ -11,24 +11,23 @@ step_1() {
exe apt update exe apt update
} }
step_2_info() { echo -e "Installing $toolname dependencies: $toolDeps"; } step_2_info() { echo -e "Installing $toolName dependencies: $toolDeps"; }
step_2() { step_2() {
exe apt install $toolDeps -y exe apt install $toolDeps -y
saveReturn $? endReturn -o $? "Installing deps for $toolName failed"
endReturn
exe service php7.3-fpm restart exe service php7.3-fpm restart
endReturn -o $? "Problems starting $toolName"
} }
step_3_info() { echo -e "Get $toolName using git"; } step_3_info() { echo -e "Get $toolName using git"; }
step_3() { step_3() {
exe git clone -b $toolTag https://github.com/pixelfed/pixelfed.git $toolPath exe git clone -b $toolTag https://github.com/pixelfed/pixelfed.git $toolPath
cd $toolPath exe cd $toolPath
exe chown -R www-data:www-data . # change user/group to http user and http group exe chown -R www-data:www-data . # change user/group to http user and http group
exe find . -type d -exec chmod 755 {} \; # set all directories to rwx by user/group exe find . -type d -exec chmod 755 {} \; # set all directories to rwx by user/group
exe find . -type f -exec chmod 644 {} \; # set all files to rw by user/group exe find . -type f -exec chmod 644 {} \; # set all files to rw by user/group
exe composer install --no-ansi --no-interaction --optimize-autoloader exe composer install --no-ansi --no-interaction --optimize-autoloader
saveReturn $? endReturn -o $? "Composer install error"
endReturn
} }
step_4_info() { echo "Create mysql database for $toolName"; } step_4_info() { echo "Create mysql database for $toolName"; }
@@ -41,11 +40,10 @@ step_4() {
exe mysql -u root -e 'SHOW DATABASES;' exe mysql -u root -e 'SHOW DATABASES;'
echo -en "Enter database name: " echo -en "Enter database name: "
read mysqlDatabase exe read mysqlDatabase
endCheckEmpty mysqlDatabase "database name" endCheckEmpty mysqlDatabase "database name"
exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4;' exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4;'
saveReturn $? endReturn -o $? "Creating database failed"
endReturn
echo "Existing mysql user:" echo "Existing mysql user:"
exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' exe mysql -u root -e 'SELECT User, Host FROM mysql.user;'
@@ -57,21 +55,19 @@ step_4() {
read -s mysqlPass read -s mysqlPass
endCheckEmpty mysqlPass "password" endCheckEmpty mysqlPass "password"
exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';'
saveReturn $? endReturn -o $? "Creating database user \"${mysqlUser}\" failed";
endReturn
exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';'
saveReturn $? endReturn -o $? "Granting privileges for user \"${mysqlUser}\" failed";
endReturn
exe mysql -u root -e 'FLUSH PRIVILEGES;' exe mysql -u root -e 'FLUSH PRIVILEGES;'
} }
step_5_info() { echo "$toolName configuration"; } step_5_info() { echo "$toolName configuration"; }
step_5() { step_5() {
cd $toolPath exe cd $toolPath
exe cp .env.example .env exe cp .env.example .env
read -p "Edit database settings, hostname, email settings, IMAGE_DRIVER=imagick, etc... (Enter to continue)" exe read -p "Edit database settings, hostname, email settings, IMAGE_DRIVER=imagick, etc... (Enter to continue)"
exe vi .env exe vi .env
exe php artisan key:generate exe php artisan key:generate
exe php artisan config:cache exe php artisan config:cache
@@ -82,16 +78,15 @@ step_5() {
step_6_info() { echo "Create admin user"; } step_6_info() { echo "Create admin user"; }
step_6() { step_6() {
cd $toolPath exe cd $toolPath
read -p "Create admin user. (Enter to continue)" exe read -p "Create admin user. (Enter to continue)"
exe php artisan user:create exe php artisan user:create
} }
step_7_info() { echo "Create pixelfed (horzion) service"; } step_7_info() { echo "Create pixelfed (horzion) service"; }
step_7() { step_7() {
addConf -c "${horizonService}" "${horizonServiceLoc}" addConf -c "${horizonService}" "${horizonServiceLoc}"
saveReturn $? endReturn -o $? "Failed to add horizon service"
endReturn
exe systemctl daemon-reload exe systemctl daemon-reload
exe systemctl enable pixelfed.service exe systemctl enable pixelfed.service
exe service pixelfed start exe service pixelfed start
@@ -100,7 +95,7 @@ step_7() {
horizonServiceLoc="/etc/systemd/system/pixelfed.service" horizonServiceLoc="/etc/systemd/system/pixelfed.service"
horizonService="\ horizonService="\
[Unit] [Unit]
Description=Pixelfeds' Horizon Description=${toolName}s' Horizon
After=syslog.target After=syslog.target
After=network.target After=network.target
#Requires=mysql.service #Requires=mysql.service
@@ -120,8 +115,8 @@ RestartSec=2s
Type=simple Type=simple
User=www-data User=www-data
Group=www-data Group=www-data
WorkingDirectory=/var/www/pixelfed/ WorkingDirectory=${toolPath}/
ExecStart=/usr/bin/php /var/www/pixelfed/artisan horizon ExecStart=/usr/bin/php ${toolPath}/artisan horizon
Restart=always Restart=always
Environment= Environment=
@@ -133,8 +128,7 @@ step_8() {
addConf -c "$nginxConfig" "$nginxConfigLoc" addConf -c "$nginxConfig" "$nginxConfigLoc"
exe ln -s "$nginxConfigLoc" "$nginxConfigEnable" exe ln -s "$nginxConfigLoc" "$nginxConfigEnable"
exe nginx -t exe nginx -t
saveReturn $? endReturn -o $? "Nginx configuration check error"
endReturn
exe service nginx restart exe service nginx restart
} }
@@ -195,7 +189,7 @@ location ~ /\\.(?!well-known).* {
step_20_info() { echo "Reload configuration (.env)"; } step_20_info() { echo "Reload configuration (.env)"; }
step_20_alias() { ALIAS="newenv"; } step_20_alias() { ALIAS="newenv"; }
step_20() { step_20() {
cd $toolPath exe cd $toolPath
exe php artisan config:cache exe php artisan config:cache
exe service pixelfed restart exe service pixelfed restart
} }
@@ -203,23 +197,24 @@ step_20() {
step_22_info() { echo "Create new user"; } step_22_info() { echo "Create new user"; }
step_22_alias() { ALIAS="createuser"; } step_22_alias() { ALIAS="createuser"; }
step_22() { step_22() {
cd $toolPath exe cd $toolPath
exe php artisan user:create exe php artisan user:create
} }
step_24_info() { echo "Checkout to dev branch. Losing local changes!"; } step_24_info() { echo "Checkout to dev branch. Losing local changes!"; }
step_24_alias() { ALIAS="forcedev"; } step_24_alias() { ALIAS="forcedev"; }
step_24() { step_24() {
read -p "Are you sure: y/n(default)? " answer exe read -p "Are you sure: y/[n]? " answer
case $answer in if [ $DRY -eq 0 ] ; then
[yY]) case $answer in
;; [yY])
*) ;;
return 1 *)
;; return 1
esac ;;
esac
cd $toolPath fi
exe cd $toolPath
exe git fetch --all exe git fetch --all
exe git reset --hard origin/dev exe git reset --hard origin/dev
exe git pull origin dev exe git pull origin dev
@@ -229,19 +224,17 @@ step_24() {
step_100_info() { echo "Upgrade \"${toolPath}\" to supported tag $toolTag"; } step_100_info() { echo "Upgrade \"${toolPath}\" to supported tag $toolTag"; }
step_100_alias() { ALIAS="upgrade"; } step_100_alias() { ALIAS="upgrade"; }
step_100() { step_100() {
cd $toolPath exe cd $toolPath
exe git pull exe git pull
saveReturn $? endReturn -o $? "git pull failed"
endReturn
exe git checkout $toolTag exe git checkout $toolTag
saveReturn $? endReturn -o $? "git checkout failed"
endReturn
} }
step_101_info() { echo "Recommended post update procedure"; } step_101_info() { echo "Recommended post update procedure"; }
step_101_alias() { ALIAS="postupdate"; } step_101_alias() { ALIAS="postupdate"; }
step_101() { step_101() {
cd $toolPath exe cd $toolPath
exe composer install --no-ansi --no-interaction --no-progress --no-scripts --optimize-autoloader exe composer install --no-ansi --no-interaction --no-progress --no-scripts --optimize-autoloader
exe php artisan config:cache exe php artisan config:cache
exe php artisan route:cache exe php artisan route:cache
@@ -252,10 +245,7 @@ step_101() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=3 VERSION_SEQREV=7
# 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 # Path to sequencer
. ${DIR}/../sequencer/sequencer.sh . sequencer.sh

View File

@@ -190,6 +190,7 @@ step_14_info() { echo "List mysql databases"; }
step_14_alias() { ALIAS="listdb"; } step_14_alias() { ALIAS="listdb"; }
step_14() { step_14() {
exe mysql -u root -e 'SHOW DATABASES;' exe mysql -u root -e 'SHOW DATABASES;'
echo -e "\nDrop userdb by: mysql -u root -e 'DROP DATABASE userdb;'"
} }
step_16_info() { echo "List mysql user"; } step_16_info() { echo "List mysql user"; }

View File

@@ -9,14 +9,13 @@ phpName="php$phpVersion"
phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu" phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${phpName}-intl ${phpName}-gd ${phpName}-zip ${phpName}-xml ${phpName}-mbstring php-imagick php-apcu"
step_1_info() { echo -e "Installation of $serverName and ${databaseName} packages:\n $serverPackages $databasePackages"; } step_1_info() { echo -e "Installation of $serverName and ${databaseName} packages:\n $serverPackages $databasePackages"; }
step_1_alias() { ALIAS=install; } step_1_alias() { ALIAS="install"; }
step_1() { step_1() {
exe apt update exe apt update
exe apt install $databasePackages exe apt install $databasePackages
saveReturn $? endReturn -o $? "Database package installation error"
endReturn
exe apt install $serverPackages exe apt install $serverPackages
saveReturn $? endReturn -o $? "Server package installation error"
} }
step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; } step_2_info() { echo "Basic nginx configuration for initial letsencrypt certificate creation"; }
@@ -36,10 +35,9 @@ step_2() {
# create webroot # create webroot
exe mkdir -p "$siteLetsencryptWww" exe mkdir -p "$siteLetsencryptWww"
echo -n "Restarting Nginx ... " echo -n " [I] Restarting Nginx ... "
exe service nginx restart && echo "ok" exe service nginx restart && echo "ok"
saveReturn $? endReturn -o $? "Nginx error during startup"
endReturn
} }
snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf" snippetLetsencryptLoc="/etc/nginx/snippets/letsencrypt.conf"
@@ -65,8 +63,10 @@ step_4_info() { echo "Mariadb configuration"; }
step_4() { step_4() {
addConf -c "$mariadbConfig" "$mariadbConfigLoc" addConf -c "$mariadbConfig" "$mariadbConfigLoc"
echo -n "Restarting mysql ... " echo -n " [I] Restarting mysql ... "
exe service mysql restart && echo "ok" exe service mysql restart
endReturn -o $? "Mariadb error during startup"
echo "ok"
} }
mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf" mariadbConfigLoc="/etc/mysql/mariadb.conf.d/90-myconfig.cnf"
@@ -83,6 +83,7 @@ lower_case_table_names=0
step_5_info() { echo -e "Installation of $phpName packages:\n $phpPackages"; } step_5_info() { echo -e "Installation of $phpName packages:\n $phpPackages"; }
step_5() { step_5() {
exe apt install $phpPackages exe apt install $phpPackages
endReturn -o $? "$phpName error during startup"
} }
phpFpmConfigLocation="/etc/php/${phpVersion}/fpm/conf.d/90-custom_pi.ini" phpFpmConfigLocation="/etc/php/${phpVersion}/fpm/conf.d/90-custom_pi.ini"
@@ -111,8 +112,10 @@ step_6() {
addConf -c "$phpFpmConfig" "$phpFpmConfigLocation" addConf -c "$phpFpmConfig" "$phpFpmConfigLocation"
addConf -c "$phpCliConfig" "$phpCliConfigLocation" addConf -c "$phpCliConfig" "$phpCliConfigLocation"
echo -n "Restarting ${phpName} ... " echo -n "Restarting ${phpName} ..."
exe service ${phpName}-fpm restart && echo "ok" exe service ${phpName}-fpm restart
endReturn -o $? "$phpName error during restart"
echo "ok"
} }
step_10_info() { echo -e "Create mysql database without specific characterset\n"; } step_10_info() { echo -e "Create mysql database without specific characterset\n"; }
@@ -184,6 +187,6 @@ step_12() {
exe mysql -u root -e 'FLUSH PRIVILEGES;' exe mysql -u root -e 'FLUSH PRIVILEGES;'
} }
VERSION_SEQREV=3 VERSION_SEQREV=7
. sequencer.sh . sequencer.sh