X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=bullseye%2Fsetup_scripts%2Fsetup_microblogpub.sh;h=d0f68c938fca59b0dbc4f72ae9655e73cd28edea;hb=08838d2da7076e05599a9076ed18da056d380cc8;hp=814f6b9d49f8f2a32d12e110171dc8a8f28557ca;hpb=118c58477dea1bbcbf1d7768469f43839f249a80;p=config diff --git a/bullseye/setup_scripts/setup_microblogpub.sh b/bullseye/setup_scripts/setup_microblogpub.sh index 814f6b9..d0f68c9 100755 --- a/bullseye/setup_scripts/setup_microblogpub.sh +++ b/bullseye/setup_scripts/setup_microblogpub.sh @@ -2,27 +2,18 @@ set -e set -x -if [ "$#" -ne 3 ] && [ "$#" -ne 4 ]; then - echo 'Need domain name and mail and init state and possibly old server IP as argument.' - false -fi -if [ ! "$3" = "copy" ] && [ ! "$3" = "new" ]; then - echo "Need init state to be either 'copy' or 'new'." - false -fi -if [ ! "$3" = "new" ] && [ "$#" -ne 4 ]; then - echo "With init state != 'new' need fifth argument old server IP." +if [ "$#" -ne 2 ]; then + echo 'Need domain name and mail.' false fi domain="$1" mail="$2" -init_state="$3" -old_server="$4" # Install configs, set up firewall. config_tree_prefix="${HOME}/config/bullseye" -./install_for_target.sh web +./install_for_target.sh web microblogpub ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web microblogpub +apt update # since we just updated /etc/apt/sources.list nft -f /etc/nftables.conf # Set up letsencrypt certificate. TODO: Is it auto-renewed? @@ -30,18 +21,38 @@ ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}" rm /etc/nginx/sites-enabled/default -# Install Python 3.10 from source (Bullseye only has 3.9). -apt build-dep python3 +# Install Python >=3.10 from source (Bullseye only has 3.9). python_version=3.11.1 -python_dirname="Python-3.1.11.1" -su -lc "wget https://www.python.org/ftp/python/3.11.1/${python_dirname}.tgz" plom +python_dirname="Python-${python_version}" +su -lc "wget https://www.python.org/ftp/python/${python_version}/${python_dirname}.tgz" plom su -lc "tar -xvf ${python_dirname}.tgz" plom -su -lc "cd ${python_dirname} && ./configure && make && make test" +su -lc "cd /home/plom/${python_dirname} && ./configure --enable-optimizations && make" cd /home/plom/${python_dirname}/ make altinstall cd +rm -rf /home/plom/${python_dirname} + +# Configure/install Poetry and microblog.pub. +su -lc "curl -sSL https://install.python-poetry.org | python3.11" - plom +su -lc "git clone https://git.sr.ht/~tsileo/microblog.pub testing.microblog.pub" - plom +su -lc "poetry config installer.parallel false" - plom +su -lc "cd testing.microblog.pub && poetry install" - plom +su -lPc "cd testing.microblog.pub && poetry run inv configuration-wizard" - plom +su -lPc "cd testing.microblog.pub && poetry run inv migrate-db" - plom + +# Set up microblog.pub daemon service. +venv_dir_path=$( su -lPc "cd testing.microblog.pub && poetry env info --path" - plom) +venv_dir=$(basename ${venv_dir_path}) +sed -i "s/REPLACE_venv_dir_ECALPER/${venv_dir}/g" /etc/systemd/system/microblogpub.service +systemctl enable microblogpub.service +service microblogpub start # Prepare and start NGINX config. sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx ln -s /etc/nginx/sites-available/microblogpub.nginx /etc/nginx/sites-enabled/microblogpub.nginx service nginx restart + +# Setup regular DB pruning +cp "${config_tree_prefix}/other_files/prune_microblog.sh" /home/plom/ +systemctl enable microblogpub_prune.timer +systemctl start microblogpub_prune.timer