# Note: Comments are unindented to not be printed during the installation .PHONY: install uninstall CLASS_FILE = /etc/login.conf.d/i2pd install: # This command verifies if the group _i2pd exists. If it doesn't, it creates # it with gid 838. groupinfo -e _i2pd || groupadd -g 838 _i2pd # These commands verify if the user _i2pd exists. If it doesn't, it creates # it with uid 838, default group 838 (which is _i2pd), login class "i2pd" # (created manually before running this script), comment "i2pd account", # home directory /var/lib/i2pd, and login shell /sbin/nologin (which forbids # it from loging in). The mkdir and chown are used instead of the -m option # of useradd in case /var/lib/i2pd already existed before the execution of # this make target. mkdir -p /var/lib/i2pd userinfo -e _i2pd || useradd -u 838 -g 838 -L i2pd \ -c "i2pd account" -d /var/lib/i2pd -s /sbin/nologin _i2pd chown -R _i2pd:_i2pd /var/lib/i2pd # This command adds a new login class allowing _i2pd to open more files # simultaneously if the version of OpenBSD is 7.1 or newer. For older # versions, the modification needs to be done manually in /etc/login.conf. if [ $$(echo "$$(uname -r) >= 7.1" | bc) = 1 ]; then \ echo "i2pd:\\" > $(CLASS_FILE); \ echo "\t:openfiles-cur=102400:\\" >> $(CLASS_FILE); \ echo "\t:openfiles-max=102400:\\" >> $(CLASS_FILE); \ echo "\t:tc=daemon:" >> $(CLASS_FILE); \ fi # This command copies the RC script in the RC script folder to allow I2Pd to # be managed by the service supervisor. install -o root -g bin -m 555 i2pd /etc/rc.d/i2pd uninstall: # This command removes the RC script. rcctl disable i2pd rm /etc/rc.d/i2pd # This command removes the i2pd login class. rm $(CLASS_FILE) # This command removes the _i2pd user and its home. userdel -r _i2pd # This command removes the _i2pd group. groupdel _i2pd