master <- easy-releases

This commit is contained in:
Arinerron 2019-07-22 16:59:48 -07:00
parent 2b17cd13f4
commit fff2b7b18f
No known key found for this signature in database
GPG key ID: 99383627861C62F0
22 changed files with 560 additions and 45 deletions

4
install/build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
make plugins-reset
find . -name '__pycache__' -type d | xargs rm -rf

52
install/create_release.py Executable file
View file

@ -0,0 +1,52 @@
import os
version = ''
contents = ''
with open('../onionr/onionr.py', 'r') as f:
contents = f.read()
version = contents.split("ONIONR_VERSION = '")[1].split("'")[0]
print('Current Onionr release version is %s (MAJOR.MINOR.VERSION)\n' % version)
new_version = input('Enter new version: ')
try:
int(new_version.replace('.', ''))
except:
print('Invalid version number, try again.')
exit(1337)
confirm = input('Please confirm the version change from %s to %s (y/N): ' % (version, new_version))
print('\n------\n')
if confirm.lower().startswith('y'):
print('- Updating version in onionr.py')
with open('../onionr/onionr.py', 'w+') as f:
f.write(contents.replace("ONIONR_VERSION = '%s'" % version, "ONIONR_VERSION = '%s'" % new_version))
print('- Updating version in PKGBUILD')
with open('../onionr/PKGBUILD', 'w+') as f:
f.write(f.read().replace("pkgver=%s" % version, "pkgver=%s" % new_version))
print('- Committing changes')
os.system('cd ..; git add onionr/onionr.py; git commit -m "Increment Onionr version to %s"' % new_version)
print('- Adding tag')
os.system('cd ..; git tag %s' % new_version)
print('- Pushing changes')
# os.system('cd ..; git push origin --tags')
print('\n------\n\nAll done. Create a merge request into master at this link:\n\nhttps://gitlab.com/beardog/Onionr/merge_requests/new?merge_request%5Bsource_project_id%5D=5020889&merge_request%5Btarget_branch%5D=master&merge_request%5Btarget_project_id%5D=5020889')
print('\nNOTE: The default configuration file was not changed. Please make sure it is not in dev mode, and that log.verbosity is "error".')
else:
print('Change cancelled. No action has been taken.')

View file

@ -22,27 +22,31 @@ fi
# install basic dependencies
pacman --needed --noconfirm -S git curl python python-pip tor
echo -e "\033[0;32mInstalling pacman dependencies...\033[0m"
! ((pacman --needed --noconfirm -S git curl python python-pip tor > /dev/null) 2>&1 | grep -v warning 1>&2) | grep .
# get the repository
echo -e "\033[0;32mCloning Onionr repository...\033[0m"
rm -rf "$OUTPUT_DIR" "$DATA_DIR" "$LOG_DIR"
git clone https://gitlab.com/beardog/onionr "$OUTPUT_DIR"
git clone --quiet https://gitlab.com/beardog/onionr "$OUTPUT_DIR" > /dev/null
cd "$OUTPUT_DIR"
git checkout "$BRANCH"
git checkout -q "$BRANCH" > /dev/null
# install python dependencies
pip3 install --no-input -r "$OUTPUT_DIR/requirements.txt" --require-hashes
echo -e "\033[0;32mInstalling pip dependencies...\033[0m"
# create nologin onionr user if not exists
pip3 install --no-input -r "$OUTPUT_DIR/requirements.txt" --require-hashes > /dev/null
id -u onionr &>/dev/null || useradd -r -s /sbin/nologin onionr
# set permissions on Onionr directory
chmod 755 "$OUTPUT_DIR"
chown -R onionr:onionr "$OUTPUT_DIR"
chown -R root:root "$OUTPUT_DIR"
# create directories
@ -50,7 +54,7 @@ mkdir -p "$OUTPUT_DIR/onionr/data" "$LOG_DIR"
mv "$OUTPUT_DIR/onionr/data" "$DATA_DIR"
chmod -R 750 "$DATA_DIR" "$LOG_DIR"
chown -R onionr:onionr "$DATA_DIR" "$LOG_DIR"
chown -R root:root "$DATA_DIR" "$LOG_DIR"
# create executable
@ -61,6 +65,8 @@ chown root:root "$EXECUTABLE"
# create systemd service
echo -e "\033[0;32mCreating systemd unit...\033[0m"
SERVICE='/etc/systemd/system/onionr.service'
cp "$OUTPUT_DIR/install/onionr.service" "$SERVICE"

View file

@ -22,27 +22,31 @@ fi
# install basic dependencies
apt -y install git curl python3.7 python3-pip python3-setuptools tor
echo -e "\033[0;32mInstalling apt dependencies...\033[0m"
apt-get install -y git curl python3.7 python3-pip python3-setuptools tor > /dev/null
# get the repository
echo -e "\033[0;32mCloning Onionr repository...\033[0m"
rm -rf "$OUTPUT_DIR" "$DATA_DIR" "$LOG_DIR"
git clone https://gitlab.com/beardog/onionr "$OUTPUT_DIR"
git clone --quiet https://gitlab.com/beardog/onionr "$OUTPUT_DIR" > /dev/null
cd "$OUTPUT_DIR"
git checkout "$BRANCH"
git checkout -q "$BRANCH" > /dev/null
# install python dependencies
python3.7 -m pip install --no-input -r "$OUTPUT_DIR/requirements.txt" --require-hashes
echo -e "\033[0;32mInstalling pip dependencies...\033[0m"
# create nologin onionr user if not exists
python3.7 -m pip install --no-input -r "$OUTPUT_DIR/requirements.txt" --require-hashes > /dev/null
id -u onionr &>/dev/null || useradd -r -s /sbin/nologin onionr
# set permissions on Onionr directory
chmod 755 "$OUTPUT_DIR"
chown -R onionr:onionr "$OUTPUT_DIR"
chown -R root:root "$OUTPUT_DIR"
# create directories
@ -50,7 +54,7 @@ mkdir -p "$OUTPUT_DIR/onionr/data" "$LOG_DIR"
mv "$OUTPUT_DIR/onionr/data" "$DATA_DIR"
chmod -R 750 "$DATA_DIR" "$LOG_DIR"
chown -R onionr:onionr "$DATA_DIR" "$LOG_DIR"
chown -R root:root "$DATA_DIR" "$LOG_DIR"
# create executable
@ -61,6 +65,8 @@ chown root:root "$EXECUTABLE"
# create systemd service
echo -e "\033[0;32mCreating systemd unit...\033[0m"
SERVICE='/etc/systemd/system/onionr.service'
cp "$OUTPUT_DIR/install/onionr.service" "$SERVICE"

View file

@ -2,11 +2,22 @@
set -e
[ "root" != "$USER" ] && exec sudo $0 "$@"
export OUTPUT_DIR=${OUTPUT_DIR:=/usr/share/onionr}
export ONIONR_HOME=${ONIONR_HOME:=/etc/onionr}
export LOG_DIR=${LOG_DIR:=/var/log/onionr}
cd "$OUTPUT_DIR"
exec su onionr -s /bin/sh -c "./onionr.sh ""$@"""
if [ -n "$HOME" ]; then
export XDG_DATA_HOME=${XDG_DATA_HOME:=$HOME/.local/share/onionr}
export ONIONR_HOME=${ONIONR_HOME:=$XDG_DATA_HOME}
export LOG_DIR=${LOG_DIR:=$XDG_DATA_HOME/logs}
else
export ONIONR_HOME=${ONIONR_HOME:=/etc/onionr}
export LOG_DIR=${LOG_DIR:=/var/log/onionr}
fi
mkdir -p "$ONIONR_HOME" "$LOG_DIR"
chmod -R 700 "$ONIONR_HOME" "$LOG_DIR"
chown -R $USER:$USER "$ONIONR_HOME" "$LOG_DIR"
cd "$OUTPUT_DIR/onionr"
exec python3.7 onionr.py "$@"

View file

@ -1,15 +1,21 @@
[Unit]
Description=Onionr Daemon
Requires=network.target tor.service
Documentation=https://onionr.net/docs/
After=network.target tor.service
Requires=network.target tor.service systemd-networkd-wait-online.service
[Service]
Environment="DATA_DIR=/usr/share/onionr"
Environment="LOG_DIR=/var/log/onionr/"
ExecStart=/usr/bin/onionr --start
ExecStop=/usr/bin/onionr --stop
KillMode=mixed
KillSignal=SIGQUIT
TimeoutStopSec=5s
Type=simple
Restart=always
Restart=on-abnormal
[Install]
WantedBy=tor.service

3
install/post_build.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/sh
sh run_tests.sh

5
install/post_install.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
systemctl daemon-reload
systemctl enable onionr
systemctl start onionr

3
install/pre_install.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
pip3 install --no-input -r "$OUTPUT_DIR/requirements.txt" --require-hashes > /dev/null