You are not logged in.
First time writing a Bash script, building from source, and day 2 of using Arch, had a few questions about this AUR process that I'm writing for PostgreSQL 10.0
Is it okay to build something from the source code through a package?
How would I go about forcing it to build to /usr/lib/$pkgname instead of /usr/local/pgsql (I tried to move it, but it didn't like the results)
Am I on the right track?
At this moment I'm trying to solicit constructive feedback. I plan on adding the following to this script to further enhance it:
A safe method for upgrades in order to not jeopardize data integrity
A safe method of removable that asks the end user if they would like to keep their data
Integration with systemctl so it can be used like other services i.e. systemctl start postgres.service
#!/bin/bash
pkgname=postgresql-10.0
#Using a temporary location for a safe deletion later on
cd ${TMPDIR-/tmp}
#Downloading the files directly from the source
$(curl -O https://ftp.postgresql.org/pub/source/v10.0/$pkgname.tar.gz)
$(curl -O https://ftp.postgresql.org/pub/source/v10.0/$pkgname.tar.gz.md5)
$(curl -O https://ftp.postgresql.org/pub/source/v10.0/$pkgname.tar.gz.sha256)
#Checks md5 and sha256, if it checks out it unpacks
if [[ $(md5sum $pkgname.tar.gz) != $(cat $pkgname.tar.gz.md5) ]]; then
echo "MD5 doesn't match, aborting..."
exit
else
if [[ $(sha256sum $pkgname.tar.gz) != $(cat $pkgname.tar.gz.sha256) ]]; then
echo "SHA256 doesn't match, aborting..."
exit
else
echo "MD5 and SHA256 both match, unpacking..."
$(tar -zxf $pkgname.tar.gz)
fi
fi
#disposing of the downloaded files
$(rm -rf $pkgname.tar.gz)
$(rm -rf $pkgname.tar.gz.md5)
$(rm -rf $pkgname.tar.gz.sha256)
#postgresql magic happens here
cd $pkgname
$(./configure)
$(make)
$(make install)
#creating the new postgres user
$(useradd -G wheel -s /bin/bash postgres)
$(usermod -d /usr/local/pgsql -m postgres)
echo "Enter a password for your database"
$(passwd postgres)
$(chown postgres /usr/local/pgsql/data)
#Actions performed by new postgres user
runuser -l postgres -c 'mkdir /usr/local/pgsql/data'
runuser -l postgres -c 'chown postgres /usr/local/pgsql/data'
runuser -l postgres -c 'chmod 700 /usr/local/pgsql/data'
runuser -l postgres -c '/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data'
runuser -l postgres -c '/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &'
runuser -l postgres -c '/usr/local/pgsql/bin/createdb test'
runuser -l postgres -c '/usr/local/pgsql/bin/psql test'
echo "To start the $pkgname server run the following as the postgres user: "
echo " -> /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile restart"Offline
You want a PKGBUILD: https://wiki.archlinux.org/index.php/Pkgbuild
Offline
You want a PKGBUILD: https://wiki.archlinux.org/index.php/Pkgbuild
+1
Browse packages to see some examples.
Last edited by graysky (2017-10-25 07:08:53)
Offline