소스 검색

Command option to register a website with monkeysphere

Bob Mottram 9 년 전
부모
커밋
a7572eabc1
1개의 변경된 파일28개의 추가작업 그리고 1개의 파일을 삭제
  1. 28
    1
      src/freedombone-sec

+ 28
- 1
src/freedombone-sec 파일 보기

352
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
352
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
353
 	  SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
353
 	  SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
354
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
354
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
355
+	  monkeysphere-host publish-key --all
355
 	  echo $'updated monkeysphere ssh host key'
356
 	  echo $'updated monkeysphere ssh host key'
356
 	  systemctl restart ssh
357
 	  systemctl restart ssh
357
   fi
358
   fi
617
 		# The admin user is the identity certifier
618
 		# The admin user is the identity certifier
618
 		fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
619
 		fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
619
 		monkeysphere-authentication add-identity-certifier $fpr
620
 		monkeysphere-authentication add-identity-certifier $fpr
620
-		monkeysphere-host publish-key
621
+		monkeysphere-host publish-key --all
621
 	else
622
 	else
622
 		sed -i 's|#AuthorizedKeysFile|AuthorizedKeysFile|g' /etc/ssh/sshd_config
623
 		sed -i 's|#AuthorizedKeysFile|AuthorizedKeysFile|g' /etc/ssh/sshd_config
623
 		sed -i 's|AuthorizedKeysFile.*|AuthorizedKeysFile %h/.ssh/authorized_keys|g' /etc/ssh/sshd_config
624
 		sed -i 's|AuthorizedKeysFile.*|AuthorizedKeysFile %h/.ssh/authorized_keys|g' /etc/ssh/sshd_config
861
 	exit 0
862
 	exit 0
862
 }
863
 }
863
 
864
 
865
+function register_website {
866
+	domain="$1"
867
+	if [[ ${domain} == *".local" ]]; then
868
+		echo $"Can't register local domains"
869
+		exit 82438
870
+	fi
871
+	if [ ! -f /etc/ssl/private/${domain}.key ]; then
872
+		echo $"No SSL/TLS private key found for ${domain}"
873
+		exit 62852
874
+	fi
875
+	if [ ! -f /etc/nginx/sites-available/${domain} ]; then
876
+		echo $"No virtual host found for ${domain}"
877
+		exit 25625
878
+	fi
879
+	monkeysphere-host import-key /etc/ssl/private/${domain}.key https://${domain}
880
+	monkeysphere-host publish-key
881
+	exit 0
882
+}
883
+
864
 function show_help {
884
 function show_help {
865
   echo ''
885
   echo ''
866
   echo "${PROJECT_NAME}-sec"
886
   echo "${PROJECT_NAME}-sec"
872
   echo $'  -e --export           Export security settings to a file'
892
   echo $'  -e --export           Export security settings to a file'
873
   echo $'  -i --import           Import security settings from a file'
893
   echo $'  -i --import           Import security settings from a file'
874
   echo $'  -r --refresh          Refresh GPG keys for all users'
894
   echo $'  -r --refresh          Refresh GPG keys for all users'
895
+  echo $'  --register [domain]   Register a https domain with monkeysphere'
875
   echo ''
896
   echo ''
876
   exit 0
897
   exit 0
877
 }
898
 }
898
 	;;
919
 	;;
899
 	# Refresh GPG keys
920
 	# Refresh GPG keys
900
 	-r|--refresh)
921
 	-r|--refresh)
922
+	shift
901
 	refresh_gpg_keys
923
 	refresh_gpg_keys
902
 	;;
924
 	;;
925
+	# register a website
926
+	--register|--reg|--site)
927
+	shift
928
+	register_website "$1"
929
+	;;
903
 	*)
930
 	*)
904
 	# unknown option
931
 	# unknown option
905
 	;;
932
 	;;