Skip to content

Commit

Permalink
Test (#87)
Browse files Browse the repository at this point in the history
* fix deletion bug

* autoImport

* buildscript

* m time instead of c time!

* Gitignore

* animation

* zoomable, better animation

* zoom fixes, better scrolling to picture

* Open in album feature

* fix

* Fix scroll resize

* Fix scrollbar, font

* Patch face download (#79)

* Update requirements.txt

* Update Dockerfile

* newest pic in album as default?

* Show newest picture as album cover

* properly select album picture

* Search features (#82)

* selection

* search changes

* fixed video and shade

* better search

* tag search

* better label fetching

* fix dockerfile

* fix dockerfile

* navigation changes

* fix detectron

* fix detectron dockerfile

* keyboard navigation

* Make the CLI installation more platform agnostic (#88)

* Create a separate script for OpenRC, including corresponding init script files for the .service files and add checks for the package managers present to make the scripts more distro-agnostic.
For distros not based on Debian/Ubuntu, skip the manual nodejs installation, as their repos generally contain more up-to date versions of it.
Remove the manual installation of postgresql altogether, the version referenced in this script is two versions behind even the debian stable branch.

* add init scripts for OpenRC. Implement checks for the presence of /etc/nginx/sites-enabled and whether it is enabled in nginx.conf

* Updated readme with information about using OpenRC

* make photo search work with new photos

* enable legacy deps

* Added map

* clear searchbar on navigation via menubar

* Folders (#98)

Added folders for albums

* do not fetch so much

* performance fix

* fix build

* fix build 2

* revert package-lock.json

* fix build 3

* fix face

* search fixes

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Marcelina Hołub <86662980+154pinkchairs@users.noreply.github.com>
  • Loading branch information
3 people committed May 27, 2024
1 parent 536bf42 commit d5d26c7
Show file tree
Hide file tree
Showing 47 changed files with 3,515 additions and 3,404 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ frontend/.eslintcache

# macOS
.DS_Store

faceFeatures/*
imageFeatures/*
autoImport/node_modules/*
import/*
analysis/*
media/*
frontend/cordova/*
24 changes: 24 additions & 0 deletions CLI-Install/ImageStoreBACK
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/sbin/openrc-run

description="ImageStore Backend"
#extra_commands="checkconfig"
#need to implement a function to check configuration for errors
extra_started_commands="reload"
depend() {
need net
after postgresql nginx
}

command="/usr/bin/npm start --prefix /etc/imagestore/backend"
command_background="yes"
start_stop_daemon_args="--quiet"
cfgfile=${cfgfile:-/etc/imagestore/backend/tsconfig.json}

pidfile="/run/$RC_SVCNAME/npm.pid"
retry="SIGTERM/20"

reload() {
ebegin "Reloading $description"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
30 changes: 30 additions & 0 deletions CLI-Install/ImageStoreFRONT
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/sbin/openrc-run

description="ImageStore Frontend"
#extra_commands="checkconfig"
extra_started_commands="reload"

depend() {
need net
after postgresql nginx
want ImageStoreBACK
}

command="/usr/bin/npx serve -w /etc/imagestore/frontend -s build -l tcp://localhost:3000"
#Not sure if npx is supposed to run in background here, if yes, please uncomment these lines:
#command_background="yes"
#start_stop_daemon_args="--quiet"
pidfile="/run/$RC_SVCNAME/npm.pid"
retry="SIGTERM/20"
cfgfile=${cfgfile:=/etc/imagestore/frontend/tsconfig.json}

reload() {
ebegin "Reloading $description"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}

#need to implement a function to check configuration for errors
#checkconfig() {
#}

96 changes: 96 additions & 0 deletions CLI-Install/install-openrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

#!/bin/bash

#Check for the package manager used by the system
if [[ $(which apk) != "apk not found" ]]; then
pkgman="apk"
install="add"
update="update"
elif [[ $(which apt) != "apt not found" ]]; then
pkgman="apt"
install="install"
update="update"
elif [[ $(which yum) != "yum not found" ]]; then
pkgman="yum"
install="install"
update="update"
elif [[ $(which pacman) != "pacman not found" ]]; then
pkgman="pacman"
install="-S"
update="-Syy"
fi

#Install the required programs

$pkgman $update

##On Debian/Ubuntu based distros gotta do a little extra for Node
if [[ "$pkgman" == "apt" ]]; then
apt install curl -y
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
apt install nodejs -y
fi

case $pkgman in

yum | apt)
$pkgman $install postgresql npm build-essential nginx -y
;;

pacman | apk)
$pkgman $install postgresql npm build-essential nginx
;;

esac

#Make an Config folder
mkdir /etc/imagestore
cp -r ../frontend /etc/imagestore/
cp -r ../backend /etc/imagestore/

#Load up the system with the proper configurations

if (ss -ln | grep ":8080")
then
loopcheck=1
read -p "Port conflict detected. Select new port to host ImageStore: " port
while [ $loopcheck -eq 1 ]
do
if [[ "$port" =~ [a-zA-Z] ]]
then
echo "Invalid input detected"
read -p "Port conflict detected. Select new port to host ImageStore: " port
else
sed -i "s/8080/$port/" default.conf
loopcheck=0
fi
done
fi

#Check if sites-enabled is present and enabled in nginx.conf
cd /etc/nginx
if [[ ! -d "sites-enabled" ]]; then
mkdir -p sites-enabled
fi

if ! grep -q '^include /etc/nginx/sites-enabled/' nginx.conf; then
sed -ir '/^http {*/a \\tinclude /etc/nginx/sites-enabled/*.conf' nginx.conf
fi

cp default.conf /etc/nginx/sites-enabled/imagestore.conf
cp ImageStoreFRONT /etc/init.d/ImageStoreFRONT
cp ImageStoreBACK /etc/init.d/ImageStoreBACK

#Init an user and the database
ranpass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)

su postgres -c "./postgresql.sh $ranpass"
echo "PGSTRING=postgres://imagestore:$ranpass@localhost:5432/imagestore" > /etc/imagestore/backend/.env

#Install node modules
cd /etc/imagestore/frontend
/usr/bin/npm i
/usr/bin/npm run-script build
cd /etc/imagestore/backend
/usr/bin/npm i
/usr/bin/npm install ts-node
56 changes: 44 additions & 12 deletions CLI-Install/imagestore-build.sh → CLI-Install/install-systemd.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
#!/bin/bash

#Need this for scriptery
apt install curl gpg -y
#Check for the package manager used by the system
if [[ $(which apk) != "apk not found" ]]; then
pkgman="apk"
install="add"
update="update"
elif [[ $(which apt) != "apt not found" ]]; then
pkgman="apt"
install="install"
update="update"
elif [[ $(which yum) != "yum not found" ]]; then
pkgman="yum"
install="install"
update="update"
elif [[ $(which pacman) != "pacman not found" ]]; then
pkgman="pacman"
install="-S"
update="-Syy"
fi

#Install the required programs
##First is Postgresql - This requires importing their repo key and repo
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
apt update
apt install -y postgresql-11

$pkgman $update

##Gotta do a little extra for Node too
##On Debian/Ubuntu based distros gotta do a little extra for Node
if [[ $pkgman == apt ]]; then
apt install curl -y
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
apt install nodejs -y
fi

case $pkgman in

yum | apt)
$pkgman $install postgresql npm build-essential nginx -y
;;

##Do the rest, no extras required
apt install npm build-essential -y
pacman | apk)
$pkgman $install postgresql npm build-essential nginx
;;

apt install nginx -y
esac

#Make an Config folder
mkdir /etc/imagestore
Expand All @@ -44,6 +65,17 @@ then
fi
done
fi

#Check if sites-enabled is present and enabled in nginx.conf
cd /etc/nginx
if [[ ! -d "sites-enabled" ]]; then
mkdir -p sites-enabled
fi

if ! grep -q '^include /etc/nginx/sites-enabled/' nginx.conf; then
sed -ir '/^http {*/a \\tinclude /etc/nginx/sites-enabled/*.conf' nginx.conf
fi

cp default.conf /etc/nginx/sites-enabled/imagestore.conf
cp ImageStoreFRONT.service /etc/systemd/system/ImageStoreFRONT.service
cp ImageStoreBACK.service /etc/systemd/system/ImageStoreBACK.service
Expand Down
Empty file modified CLI-Install/postgresql.sh
100755 → 100644
Empty file.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,37 @@ Requirements:
If you want to build yourself, then clone this repo and run ```docker-compose -f docker-compose-build.yml up```. Again, you can use ```--profile``` to add features.

### Without docker
Requires Ubuntu 18.04/20.04.
Requires a distribution with any of the four following packaging systems: pacman, yum, apt, apk and either systemd or OpenRC.

```
git clone https://github.com/gregordr/ImageStore
cd CLI-Install
sudo ./imagestore-build.sh
```
This will install and configure everything as needed in order to host ImageStore. PostgreSQL 11, Nodejs and nginx will be installed.
If you're using systemd (most distros):

`sudo ./install-systemd.sh`

If you're using OpenRC (e.g. Artix, Void, Alpine; Gentoo is not supported – see above):

`sudo ./install-openrc.sh`
If you are using `doas`, please use `su -c` instead.

This will install and configure everything as needed in order to host ImageStore. PostgreSQL 13 (most Debian/Ubuntu based distros), on other distros it'll most likely be PostgreSQL 14, Nodejs and nginx will be installed.
By default it hosts over port 8080. If it is already in use, it will ask for an alternate port. The created database user is seeded with a random 16 character string, so there is no default password to worry about.

The Imagestore service by default will start on boot. To stop Imagestore, run
The Imagestore service by default will start on boot. To stop Imagestore, on systemd run
```sudo systemctl stop ImageStoreFRONT.service; sudo systemctl stop ImageStoreBACK.service;```

on OpenRC run:
```sudo rc-service ImageStoreFRONT stop && sudo rc-service ImageStoreBACK stop```

To prevent the service from starting on boot, run
```sudo systemctl disable ImageStoreFRONT.service; sudo systemctl disable ImageStoreBACK.service;```

on OpenRC run:

```sudo rc-update disable ImageStoreFRONT && sudo rc-update disable ImageStoreBACK```

### Notes for raspberry Pi:

Incase you get an error with the backend saying unreachable code, you might have to run the following commands:
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install ffmpeg python3 ca-certificates curl make g++ -y
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
RUN update-ca-certificates --fresh
WORKDIR /code
Expand Down
Loading

0 comments on commit d5d26c7

Please sign in to comment.