123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #!/bin/sh
- # -*- coding: utf-8 -*-
- basedir="$(realpath "$0" | xargs dirname)"
- info()
- {
- echo "--- $*"
- }
- error()
- {
- echo "=== ERROR: $*" >&2
- }
- warning()
- {
- echo "=== WARNING: $*" >&2
- }
- die()
- {
- error "$*"
- exit 1
- }
- do_install()
- {
- info "install $*"
- install "$@" || die "Failed install $*"
- }
- do_systemctl()
- {
- info "systemctl $*"
- systemctl "$@" || die "Failed to systemctl $*"
- }
- do_chown()
- {
- info "chown $*"
- chown "$@" || die "Failed to chown $*"
- }
- do_chmod()
- {
- info "chmod $*"
- chmod "$@" || die "Failed to chmod $*"
- }
- try_systemctl()
- {
- info "systemctl $*"
- systemctl "$@" 2>/dev/null
- }
- do_chown()
- {
- info "chown $*"
- chown "$@" || die "Failed to chown $*"
- }
- do_chmod()
- {
- info "chmod $*"
- chmod "$@" || die "Failed to chmod $*"
- }
- entry_checks()
- {
- [ -d "$target" ] || die "feedreader is not built! Run ./build.sh"
- [ "$(id -u)" = "0" ] || die "Must be root to install feedreader."
- }
- stop_services()
- {
- try_systemctl stop feedsd.service
- try_systemctl disable feedsd.service
- }
- start_services()
- {
- do_systemctl start feedsd.service
- }
- install_dirs()
- {
- do_install \
- -o root -g root -m 0755 \
- -d /opt/feedreader/bin
- do_install \
- -o root -g root -m 0755 \
- -d /opt/feedreader/lib/cgi-bin
- do_install \
- -o root -g root -m 0755 \
- -d /opt/feedreader/var/lib
- do_install \
- -o root -g www-data -m 0775 \
- -d /opt/feedreader/var/lib/feedreader
- do_install \
- -o root -g root -m 0755 \
- -d /opt/feedreader/share/feedreader
- }
- install_feedsd()
- {
- do_install \
- -o root -g root -m 0755 \
- "$target/feedsd" \
- /opt/feedreader/bin/
- do_install \
- -o root -g root -m 0644 \
- "$basedir/feedsd/feedsd.service" \
- /etc/systemd/system/
- do_systemctl enable feedsd.service
- }
- install_feeds()
- {
- do_install \
- -o root -g root -m 0755 \
- "$target/feeds" \
- /opt/feedreader/lib/cgi-bin/
- do_install \
- -o root -g root -m 0644 \
- "$basedir/resources/icon.png" \
- /opt/feedreader/share/feedreader/
- do_install \
- -o root -g root -m 0644 \
- "$basedir/resources/style.css" \
- /opt/feedreader/share/feedreader/
- }
- install_feedscli()
- {
- do_install \
- -o root -g root -m 0755 \
- "$target/feedscli" \
- /opt/feedreader/bin/
- }
- release="release"
- while [ $# -ge 1 ]; do
- case "$1" in
- --debug|-d)
- release="debug"
- ;;
- --release|-r)
- release="release"
- ;;
- *)
- die "Invalid option: $1"
- ;;
- esac
- shift
- done
- target="$basedir/target/$release"
- entry_checks
- stop_services
- install_dirs
- install_feedsd
- install_feeds
- install_feedscli
- start_services
- # vim: ts=4 sw=4 expandtab
|