Skip to content

Commit

Permalink
build: use a separate file for NCP database config
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Sep 23, 2018
1 parent 1bfcebc commit a7f0fd2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/ncp-diag
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SWP="$( swapon | tail -1 | awk '{ print $1 }' )"
echo "swapfile|$SWP"

# Database
DBDIR=$( grep datadir /etc/mysql/mariadb.conf.d/50-server.cnf | awk -F "= " '{ print $2 }' )
DBDIR=$( grep datadir /etc/mysql/mariadb.conf.d/90-ncp.cnf | awk -F "= " '{ print $2 }' )
test -d "$DBDIR" || DBDIRINFO=" (doesn't exist)"
echo "dbdir|$DBDIR$DBDIRINFO"

Expand Down
2 changes: 1 addition & 1 deletion docker-armhf/lamp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mysqladmin -u root shutdown; \
# mariaDB fixups (move database to /data-ro, which will be in a persistent volume)
mkdir -p /data-ro /data; \
mv /var/lib/mysql /data-ro/database; \
sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/50-server.cnf; \
sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf; \

# package cleanup
apt-get autoremove -y; \
Expand Down
2 changes: 1 addition & 1 deletion docker-common/lamp/010lamp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo "Starting Apache"
/usr/sbin/apache2ctl start

# adjust the dbdir to the persistent storage
sed -i "s|^datadir.*|datadir = /data/database|" /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i "s|^datadir.*|datadir = /data/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf

# start
echo "Starting mariaDB"
Expand Down
2 changes: 1 addition & 1 deletion docker/lamp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mysqladmin -u root shutdown; \
# mariaDB fixups (move database to /data-ro, which will be in a persistent volume)
mkdir -p /data-ro /data; \
mv /var/lib/mysql /data-ro/database; \
sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/50-server.cnf; \
sed -i "s|^datadir.*|datadir = /data-ro/database|" /etc/mysql/mariadb.conf.d/90-ncp.cnf; \

# package cleanup
apt-get autoremove -y; \
Expand Down
6 changes: 3 additions & 3 deletions etc/ncp-config.d/nc-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ or the database will fail.

is_active()
{
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/50-server.cnf | awk -F "= " '{ print $2 }' )
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/90-ncp.cnf | awk -F "= " '{ print $2 }' )
[[ "$SRCDIR" != "/var/lib/mysql" ]]
}

configure()
{
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/50-server.cnf | awk -F "= " '{ print $2 }' )
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/90-ncp.cnf | awk -F "= " '{ print $2 }' )
[ -d "$SRCDIR" ] || { echo -e "database directory $SRCDIR not found"; return 1; }

[ -d "$DBDIR_" ] && {
Expand All @@ -54,7 +54,7 @@ configure()
echo "moving database to $DBDIR_..."
service mysql stop
mv "$SRCDIR" "$DBDIR_" && \
sed -i "s|^datadir.*|datadir = $DBDIR_|" /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i "s|^datadir.*|datadir = $DBDIR_|" /etc/mysql/mariadb.conf.d/90-ncp.cnf
service mysql start

sudo -u www-data php occ maintenance:mode --off
Expand Down
7 changes: 4 additions & 3 deletions lamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ EOF
$APTINSTALL ssl-cert # self signed snakeoil certs

# configure MariaDB ( UTF8 4 byte support )
sed -i '/\[mysqld\]/ainnodb_large_prefix=on' /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i '/\[mysqld\]/ainnodb_file_per_table=1' /etc/mysql/mariadb.conf.d/50-server.cnf
sed -i '/\[mysqld\]/ainnodb_file_format=barracuda' /etc/mysql/mariadb.conf.d/50-server.cnf
cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/90-ncp.cnf
sed -i '/\[mysqld\]/ainnodb_large_prefix=on' /etc/mysql/mariadb.conf.d/90-ncp.cnf
sed -i '/\[mysqld\]/ainnodb_file_per_table=1' /etc/mysql/mariadb.conf.d/90-ncp.cnf
sed -i '/\[mysqld\]/ainnodb_file_format=barracuda' /etc/mysql/mariadb.conf.d/90-ncp.cnf

# launch mariadb if not already running
if ! pgrep -c mysqld &>/dev/null; then
Expand Down
7 changes: 7 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ EOF
# install preview generator
sudo -u www-data php /var/www/nextcloud/occ app:install previewgenerator
sudo -u www-data php /var/www/nextcloud/occ app:enable previewgenerator

# use separate db config file
[[ -f /etc/mysql/mariadb.conf.d/90-ncp.cnf ]] || {
cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/90-ncp.cnf
service mysql restart
}

} # end - only live updates

exit 0
Expand Down

0 comments on commit a7f0fd2

Please sign in to comment.