From e5e06ed7d65d11de257782984ec4f56c9d45aa3a Mon Sep 17 00:00:00 2001 From: Kuoi Date: Mon, 8 May 2023 02:33:23 +0800 Subject: [PATCH] init --- Dockerfile | 5 +++++ bio_junest.sh | 32 +++++++++++++++++++++++++++++ biojunest.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ gen_junest.sh | 13 ++++++++++++ junest.service | 7 +++++++ junest.timer | 7 +++++++ man_junest.sh | 8 ++++++++ 7 files changed, 127 insertions(+) create mode 100644 Dockerfile create mode 100755 bio_junest.sh create mode 100755 biojunest.sh create mode 100755 gen_junest.sh create mode 100644 junest.service create mode 100644 junest.timer create mode 100755 man_junest.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0bf017 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM bioarchlinux/bioarchlinux:latest +# import bioarchlinux keyring +RUN pacman -Syu --noconfirm bubblewrap git groot junest proot qemu-user-static sudo-fake yay +RUN mkdir /etc/junest && echo "JUNEST_ARCH=x86_64" >> /etc/junest/info +RUN rm -rf /var/cache/pacman/pkg diff --git a/bio_junest.sh b/bio_junest.sh new file mode 100755 index 0000000..d58b8be --- /dev/null +++ b/bio_junest.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# This script checks if git, curl or wget are available and downloads https://github.com/fsquillace/junest.git to ~/.junest + +# Check if git is available +#if command -v git &> /dev/null; then + # Use git to clone the repository +# git clone https://github.com/fsquillace/junest.git ~/.junest +# exit 0 +#fi + +# Check if curl and zip are available +if command -v curl &> /dev/null && command -v zip &> /dev/null; then + # Use curl to download the repository as a zip file and extract it + curl -L https://github.com/fsquillace/junest/archive/refs/heads/master.zip -o junest.zip + unzip junest.zip -d ~/.junest + rm junest.zip + exit 0 +fi + +# Check if wget and zip are available +if command -v wget &> /dev/null && command -v zip &> /dev/null; then + # Use wget to download the repository as a zip file and extract it + wget https://github.com/fsquillace/junest/archive/refs/heads/master.zip -O junest.zip + unzip junest.zip -d ~/.junest + rm junest.zip + exit 0 +fi + +# If none of the commands are available, print an error message and exit with non-zero code +echo "Error: curl/wget or zip are not available on this system." +exit + diff --git a/biojunest.sh b/biojunest.sh new file mode 100755 index 0000000..daaa428 --- /dev/null +++ b/biojunest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# This script downloads and installs junest with optional mirror and help options + +# Define the default mirror url +MIRROR="https://repo.bioarchlinux.org" + +# Parse the options using getopts +while getopts "m:h" opt; do + case $opt in + m) # Set the mirror url to the argument of -m option + MIRROR="$OPTARG" + ;; + h) # Print the help message and exit + echo "Usage: ./install [-m MIRROR] [-h]" + echo " -m MIRROR Specify a mirror url to download junest from" + echo " -h Show this help message and exit" + exit 0 + ;; + \?) # Print an error message for invalid options and exit + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# Check if curl and zip are available +if command -v curl &> /dev/null && command -v zip &> /dev/null; then + # Use curl to download the repository as a zip file and extract it + curl -L https://github.com/fsquillace/junest/archive/refs/heads/master.zip -o ~/junest.zip + unzip junest.zip -d ~/.local/share/junest + rm ~/junest.zip + curl -L "$MIRROR"/junest/bioarchlinux-junest.tar.gz -o ~/bioarchlinux-junest.tar.gz + export PATH=~/.local/share/junest/bin:$PATH + junest s -i ~/bioarchlinux-junest.tar.gz + echo "Please add `export PATH=~/.local/share/junest/bin:$PATH` to your .zshrc or .bashrc" + exit 0 +fi + +# Check if wget and zip are available +if command -v wget &> /dev/null && command -v zip &> /dev/null; then + # Use wget to download the repository as a zip file and extract it + wget https://github.com/fsquillace/junest/archive/refs/heads/master.zip -O junest.zip + unzip junest.zip -d ~/.local/share/junest + rm junest.zip + wget "$MIRROR"/junest/bioarchlinux-junest.tar.gz -O ~/bioarchlinux-junest.tar.gz + export PATH=~/.local/share/junest/bin:$PATH + junest s -i ~/bioarchlinux-junest.tar.gz + echo "Please add `export PATH=~/.local/share/junest/bin:$PATH` to your .zshrc or .bashrc" + exit 0 +fi + +# If none of the commands are available, print an error message and exit with non-zero code +echo "Error: curl/wget or zip are not available on this system." +exit 1 + diff --git a/gen_junest.sh b/gen_junest.sh new file mode 100755 index 0000000..1e4d823 --- /dev/null +++ b/gen_junest.sh @@ -0,0 +1,13 @@ +# make image follow the junest image request +docker build -t junest . + +# run image to export tar +docker run -d --name jun junest +docker export jun > bioarchlinux-junest.tar + +# generate tar.gz +gzip bioarchlinux-junest.tar + +# clean +docker rm jun --force +docker rmi junest --force diff --git a/junest.service b/junest.service new file mode 100644 index 0000000..7f5c7e9 --- /dev/null +++ b/junest.service @@ -0,0 +1,7 @@ +[Unit] +Description=junest tar.gz file generator +Wants=junest.timer +[Service] +User=root +Type=simple +ExecStart=/usr/share/lilac/junest/man_junest.sh diff --git a/junest.timer b/junest.timer new file mode 100644 index 0000000..c84f6c9 --- /dev/null +++ b/junest.timer @@ -0,0 +1,7 @@ +[Unit] +Description=Runs junest generator every Mon +[Timer] +OnCalendar=Mon *-*-* 04:00:00 +Unit=junest.service +[Install] +WantedBy=multi-user.target diff --git a/man_junest.sh b/man_junest.sh new file mode 100755 index 0000000..65e31ce --- /dev/null +++ b/man_junest.sh @@ -0,0 +1,8 @@ + +cd /usr/share/lilac/junest +git pull + +./gen_junest.sh + +rm /usr/share/lilac/Repo/junest/* +mv bioarchlinux-junest.tar.gz /usr/share/lilac/Repo/junest/