Added more advanced extension integration - extensions can now ship a config file that allows them to be ran by passing arguments to sshyp

Former-commit-id: 249674dd5fd66b064365a192f3cd43e200e3bd34
Former-commit-id: 4df1ffcf3152ca19d6c9afd69f997efc3b650ad0
This commit is contained in:
2023-02-26 02:19:20 -05:00
parent eefedde98c
commit a2f2525df1
2 changed files with 28 additions and 7 deletions
+22 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from os import chmod, environ, listdir, remove, uname, walk from os import chmod, environ, listdir, remove, uname, walk
from os.path import expanduser, isdir from os.path import expanduser, isdir, realpath
from pathlib import Path from pathlib import Path
from random import randint from random import randint
from shutil import get_terminal_size, move, rmtree from shutil import get_terminal_size, move, rmtree
@@ -791,6 +791,24 @@ def remove_data(): # deletes an entry from the server and flags it for local de
offline_delete(_entry_name, 'locally') offline_delete(_entry_name, 'locally')
def extension_runner():
from configparser import ConfigParser
_output_com, _extension_dir = None, realpath(__file__).rsplit('/', 1)[0] + '/extensions/'
for _extension in listdir(_extension_dir):
_extension_config = ConfigParser()
_extension_config.read(_extension_dir + _extension)
_input_com = _extension_config.get('config', 'input').split()
if _input_com == arguments[arg_start:]:
if arg_start == 1:
_output_com = _extension_config.get('config', 'output').split().insert(0, arguments[0])
else:
_output_com = _extension_config.get('config', 'output').split()
if _output_com is not None:
run(_output_com)
else:
print_info()
if __name__ == "__main__": if __name__ == "__main__":
try: try:
ssh_error, success_flag, sync_flag, silent_sync = False, False, False, False ssh_error, success_flag, sync_flag, silent_sync = False, False, False, False
@@ -895,6 +913,9 @@ if __name__ == "__main__":
whitelist_manage() whitelist_manage()
if success_flag == 0 and arguments[0] != 'sync': if success_flag == 0 and arguments[0] != 'sync':
if device_type == 'client' and arguments[arg_start] not in ('help', '-h'):
extension_runner()
else:
print_info() print_info()
elif (not ssh_error and sync_flag) or arguments[0] == 'sync': elif (not ssh_error and sync_flag) or arguments[0] == 'sync':
sync() sync()
+5 -5
View File
@@ -9,7 +9,7 @@ fi
_create_generic() { _create_generic() {
echo -e '\npackaging as generic...\n' echo -e '\npackaging as generic...\n'
mkdir -p output/generictemp/usr/{bin,lib/sshyp,share/{man/man1,bash-completion/completions}} mkdir -p output/generictemp/usr/{bin,lib/sshyp/extensions,share/{man/man1,bash-completion/completions}}
cp -r lib/. output/generictemp/usr/lib/sshyp/ cp -r lib/. output/generictemp/usr/lib/sshyp/
ln -s /usr/lib/sshyp/sshyp.py output/generictemp/usr/bin/sshyp ln -s /usr/lib/sshyp/sshyp.py output/generictemp/usr/bin/sshyp
cp -r share output/generictemp/usr/ cp -r share output/generictemp/usr/
@@ -74,7 +74,7 @@ sha512sums=\"
_create_hpkg() { _create_hpkg() {
echo -e '\npackaging for Haiku...\n' echo -e '\npackaging for Haiku...\n'
mkdir -p output/haikutemp/{bin,lib/sshyp,documentation/{packages/sshyp,man/man1},data/bash-completion/completions} mkdir -p output/haikutemp/{bin,lib/sshyp/extensions,documentation/{packages/sshyp,man/man1},data/bash-completion/completions}
echo "name sshyp echo "name sshyp
version "$version"-"$revision" version "$version"-"$revision"
architecture any architecture any
@@ -121,7 +121,7 @@ urls {
_create_deb() { _create_deb() {
echo -e '\npackaging for Debian/Ubuntu...\n' echo -e '\npackaging for Debian/Ubuntu...\n'
mkdir -p output/debiantemp/sshyp_"$version"-"$revision"_all/{DEBIAN,usr/{lib/sshyp,bin,share/{bash-completion/completions,man/man1}}} mkdir -p output/debiantemp/sshyp_"$version"-"$revision"_all/{DEBIAN,usr/{lib/sshyp/extensions,bin,share/{bash-completion/completions,man/man1}}}
echo "Package: sshyp echo "Package: sshyp
Version: $version Version: $version
Section: utils Section: utils
@@ -147,7 +147,7 @@ Installed-Size: 14584
_create_termux() { _create_termux() {
echo -e '\npackaging for Termux...\n' echo -e '\npackaging for Termux...\n'
mkdir -p output/termuxtemp/sshyp_"$version"-"$revision"_all_termux/{DEBIAN,data/data/com.termux/files/usr/{lib/sshyp,bin,share/{bash-completion/completions,man/man1}}} mkdir -p output/termuxtemp/sshyp_"$version"-"$revision"_all_termux/{DEBIAN,data/data/com.termux/files/usr/{lib/sshyp/extensions,bin,share/{bash-completion/completions,man/man1}}}
echo "Package: sshyp echo "Package: sshyp
Version: $version Version: $version
Section: utils Section: utils
@@ -209,7 +209,7 @@ echo -e "\nFedora packaging complete\n"
_create_freebsd_pkg() { _create_freebsd_pkg() {
echo -e '\npackaging for FreeBSD...' echo -e '\npackaging for FreeBSD...'
mkdir -p output/freebsdtemp/usr/{lib/sshyp,bin,share/{bash-completion/completions,man/man1}} mkdir -p output/freebsdtemp/usr/{lib/sshyp/extensions,bin,share/{bash-completion/completions,man/man1}}
echo "name: sshyp echo "name: sshyp
version: \""$version"\" version: \""$version"\"
abi = \"FreeBSD:13:*\"; abi = \"FreeBSD:13:*\";