mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 04:46:34 -04:00
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:
+23
-2
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
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 random import randint
|
||||
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')
|
||||
|
||||
|
||||
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__":
|
||||
try:
|
||||
ssh_error, success_flag, sync_flag, silent_sync = False, False, False, False
|
||||
@@ -895,7 +913,10 @@ if __name__ == "__main__":
|
||||
whitelist_manage()
|
||||
|
||||
if success_flag == 0 and arguments[0] != 'sync':
|
||||
print_info()
|
||||
if device_type == 'client' and arguments[arg_start] not in ('help', '-h'):
|
||||
extension_runner()
|
||||
else:
|
||||
print_info()
|
||||
elif (not ssh_error and sync_flag) or arguments[0] == 'sync':
|
||||
sync()
|
||||
|
||||
|
||||
+5
-5
@@ -9,7 +9,7 @@ fi
|
||||
|
||||
_create_generic() {
|
||||
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/
|
||||
ln -s /usr/lib/sshyp/sshyp.py output/generictemp/usr/bin/sshyp
|
||||
cp -r share output/generictemp/usr/
|
||||
@@ -74,7 +74,7 @@ sha512sums=\"
|
||||
|
||||
_create_hpkg() {
|
||||
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
|
||||
version "$version"-"$revision"
|
||||
architecture any
|
||||
@@ -121,7 +121,7 @@ urls {
|
||||
|
||||
_create_deb() {
|
||||
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
|
||||
Version: $version
|
||||
Section: utils
|
||||
@@ -147,7 +147,7 @@ Installed-Size: 14584
|
||||
|
||||
_create_termux() {
|
||||
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
|
||||
Version: $version
|
||||
Section: utils
|
||||
@@ -209,7 +209,7 @@ echo -e "\nFedora packaging complete\n"
|
||||
|
||||
_create_freebsd_pkg() {
|
||||
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
|
||||
version: \""$version"\"
|
||||
abi = \"FreeBSD:13:*\";
|
||||
|
||||
Reference in New Issue
Block a user