diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cef2199 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +src/ +pkg/ +*.tar.xz diff --git a/Admin/Makefile b/Admin/Makefile index f45187e..a732e26 100644 --- a/Admin/Makefile +++ b/Admin/Makefile @@ -1,6 +1,6 @@ LIST=arch-update close-guest fix-sound log-guest open-guest restart-service silent-guardian revproxy simple-web wifi wifiboot -LOCATION=/root/bin -INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash +LOCATION=${pkgbuild}/root/bin +INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | bash PERMISSION=0700 compile: ${LIST} ./wifi.service @@ -8,22 +8,22 @@ compile: ${LIST} ./wifi.service install: compile mkdir -p ${LOCATION}; - mkdir -p /var/log/aninix/ + mkdir -p ${pkgbuild}/var/log/aninix/ for i in ${LIST}; do cp ./$$i ${LOCATION}; done - cp ./wifi.service /usr/lib/systemd/system/wifi.service + cp ./wifi.service ${pkgbuild}/usr/lib/systemd/system/wifi.service make checkperm reverse: for i in ${LIST}; do cp ${LOCATION}/$$i .; done - cp /usr/lib/systemd/system/wifi.service . + cp ${pkgbuild}/usr/lib/systemd/system/wifi.service . test: ${LIST} - for i in ${LIST}; do [ "$$(grep -c '#/bin/bash' $$i)" -ne 1 ]; done + for i in ${LIST}; do [ "$$(grep -c '#!/bin/bash' $$i)" -ne 1 ]; done checkperm: for i in ${LIST}; do chown root:root ${LOCATION}/$$i; chmod ${PERMISSION} ${LOCATION}/$$i; done - chown root: /usr/lib/systemd/system/wifi.service; - chmod 0644 /usr/lib/systemd/system/wifi.service + chown root: ${pkgbuild}/usr/lib/systemd/system/wifi.service; + chmod 0644 ${pkgbuild}/usr/lib/systemd/system/wifi.service clean: @echo Nothing to do. diff --git a/Admin/arch-update b/Admin/arch-update index 8b8d8f4..fe069e3 100755 --- a/Admin/arch-update +++ b/Admin/arch-update @@ -20,7 +20,7 @@ echo == Updating Arch Packages == | tee -a $logfile if [ ! -z "$apply" ]; then pacman -Syu 2>&1 | tee -a $logfile # I've been having troubles with this causing crashes while online. # Hook for MediaWiki - if [ `grep $(date +$F) /var/log/pacman.log | grep -c mediawiki` -eq 1 ] && [ -d /usr/share/webapps/mediawiki ]; then + if [ `grep $(date +%F) /var/log/pacman.log | grep -c mediawiki` -eq 1 ] && [ -d /usr/share/webapps/mediawiki ]; then php /usr/share/webapps/mediawiki/maintenance/update.php | tee -a $logfile for i in `find /usr/share/webapps/ -maxdepth 1 -type d | grep mediawiki\-`; do rsync -avz --exclude images --exclude Images --exclude LocalSettings.php /usr/share/webapps/mediawiki/ "$i" @@ -28,7 +28,7 @@ if [ ! -z "$apply" ]; then done fi # Hook for Grimoire - if [ `grep $(date +$F) /var/log/pacman.log | grep -c 'upgraded postgresql '` -eq 1 ]; then + if [ `grep $(date +%F) /var/log/pacman.log | grep -c 'upgraded postgresql '` -eq 1 ]; then echo "Updating PostGreSQL databases" | tee -a $logfile #Clear old backups. rm -Rf /var/lib/postgres/olddata diff --git a/Makefile b/Makefile index 00898a6..f38ae1f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ LIST=Admin Shared ShadowArch -compile: ${LIST} ./wifi.service +compile: ${LIST} for i in ${LIST}; do make -C ./$$i; done install: compile diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..f9fcedb --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,46 @@ +# Maintainer: Shikoba Kage +pkgname=aninix-misc-scripts +pkgver=0.1.d2deb6bee364f1ad7480cb5d97ea74252c266032 +pkgver() { + printf "0.1.""$(git rev-parse HEAD)" +} +pkgrel=1 +epoch= +pkgdesc="AniNIX::MiscScripts \\\\ Miscellaneous administrative and otherwise helpful scripts" +arch=("x86_64") +url="https://aninix.net/foundation/MiscScripts" +license=('custom') +groups=() +depends=('curl' 'grep' 'bash>=4.4' 'git>=2.13') +makedepends=('make>=4.2') +checkdepends=() +optdepends=() +provides=('aninix-misc-scripts') +conflicts=() +replaces=() +backup=() +options=() +install= +changelog= +source=() +noextract=() +md5sums=() +validpgpkeys=() + +prepare() { + git pull +} + +build() { + make -C .. +} + +check() { + printf 'quit\n\n' | make -C .. test +} + +package() { + export pkgdir="${pkgdir}" + make -C .. install + install -D -m644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" +} diff --git a/Shared/Makefile b/Shared/Makefile index cf51c56..6f73e11 100644 --- a/Shared/Makefile +++ b/Shared/Makefile @@ -1,5 +1,5 @@ -LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip new-irssi-config replicate-ssh-profiles worktrack -LOCATION=/usr/local/bin +LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip new-irssi-config replicate-ssh-profiles worktrack ssh-authorize-host +LOCATION=${pkgbuild}/usr/local/bin INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash PERMISSION=0755 compile: diff --git a/Shared/ssh-authorize-host b/Shared/ssh-authorize-host new file mode 100755 index 0000000..066a49d --- /dev/null +++ b/Shared/ssh-authorize-host @@ -0,0 +1,41 @@ +#!/bin/bash + +#--------------------------------------------------------------------# +#File: ssh-authorize-host +# +#Description: Add a public key to a remote SSH-capable host. +# +#Package: AniNIX::MiscScripts +#Copyright: WTFPL +# +#Author: DarkFeather +#Changelog by editor: +#--------------------------------------------------------------------# + + +# Show the usage for this script. +function usage { + echo "Usage: $0 host [ pubkeyfile ]" +} + +# Create the initial SSH command. +function initialSSHCommand() { + echo 'mkdir -p ${HOME}/.ssh' + echo 'touch ${HOME}/.ssh/authorized_keys' + echo 'chmod 0700 ${HOME} ${HOME}/.ssh' + echo 'chmod 0600 ${HOME}/.ssh/authorized_keys' + echo 'chown -R `whoami`":" ${HOME}' + echo 'cat > ${HOME}/.ssh/authorized_keys' +} + + +# Parse the CLI arguments. +host="$1" +if [ -z "$host" ]; then usage; exit 1; fi +pubkeyfile="$2" +if [ -z "$pubkeyfile" ] || [ ! -f "$pubkeyfile" ]; then + pubkeyfile="${HOME}/.ssh/id_rsa.pub" +fi + +# Execute on the remote host. +(initialSSHCommand; cat "$pubkeyfile") | ssh "$host" /bin/bash diff --git a/Shared/whatismyip b/Shared/whatismyip index 6ed448d..93b2696 100755 --- a/Shared/whatismyip +++ b/Shared/whatismyip @@ -1,2 +1,2 @@ #!/bin/bash -/usr/bin/lynx -connect_timeout=5 -read_timeout=5 -timeout=5 --dump whatismyipaddress.com | grep '/ip/' | head -n 1 | cut -f 5 -d '/' +/usr/bin/lynx -connect_timeout=5 -read_timeout=5 --dump whatismyipaddress.com | grep '/ip/' | head -n 1 | cut -f 5 -d '/'