a
This commit is contained in:
		
					parent
					
						
							
								d18df6f801
							
						
					
				
			
			
				commit
				
					
						a64b411ad4
					
				
			
		
					 14 changed files with 3 additions and 103 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| .vscode | ||||
|  | @ -1,39 +0,0 @@ | |||
| #/bin/sh | ||||
| 
 | ||||
| if [ $# -lt 2 ]; then | ||||
|     echo "Insufficient Args" | ||||
|     echo "Please pass IPv6 address like [2a0a:e5c0:0:2:0:b3ff:fe39:7994] and password of root" | ||||
|     exit 1 | ||||
| fi | ||||
| 
 | ||||
| # Enable Alpine (3.10 + Edge) Repos | ||||
| cat > /etc/apk/repositories << EOF | ||||
| http://dl-cdn.alpinelinux.org/alpine/v3.10/main | ||||
| http://dl-cdn.alpinelinux.org/alpine/v3.10/community | ||||
| http://dl-cdn.alpinelinux.org/alpine/edge/main | ||||
| http://dl-cdn.alpinelinux.org/alpine/edge/community | ||||
| http://dl-cdn.alpinelinux.org/alpine/edge/testing | ||||
| EOF | ||||
| 
 | ||||
| 
 | ||||
| # Update Package List and Upgrade System | ||||
| apk update | ||||
| apk upgrade | ||||
| 
 | ||||
| apk add etcd etcd-ctl | ||||
| 
 | ||||
| sed -i -e "s/localhost/$1/g" /etc/etcd/conf.yml | ||||
| 
 | ||||
| # Should be made better | ||||
| sed -i -e "s/initial-cluster:/initial-cluster: http:\/\/$1:2380/g" /etc/etcd/conf.yml | ||||
| 
 | ||||
| echo 'alias etcdctl="ETCDCTL_API=3 etcdctl"' >> ~/.bashrc | ||||
| source ~/.bashrc | ||||
| 
 | ||||
| service etcd start | ||||
| rc-update add etcd | ||||
| 
 | ||||
| 
 | ||||
| etcdctl --endpoints http://$1:2379 user add root:$2 | ||||
| etcdctl --endpoints http://$1:2379 user grant-role root root | ||||
| etcdctl --endpoints http://$1:2379 auth enable | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										33
									
								
								app/abk.py
									
										
									
									
									
								
							
							
						
						
									
										33
									
								
								app/abk.py
									
										
									
									
									
								
							|  | @ -1,33 +0,0 @@ | |||
| import subprocess | ||||
| import os | ||||
| 
 | ||||
| from pipfile import  Pipfile | ||||
| 
 | ||||
| 
 | ||||
| def globally_installed_py_packages(): | ||||
|     output = subprocess.check_output("pip list --format freeze".split(), env={}) | ||||
|     output = output.decode("utf-8") | ||||
|     output = output.strip() | ||||
|     global_packages = output.split("\n") | ||||
|     return global_packages | ||||
| 
 | ||||
| 
 | ||||
| global_packages = globally_installed_py_packages() | ||||
| 
 | ||||
| name = "cow" | ||||
| p = Pipfile.load(filename=name) | ||||
| content = "" | ||||
| with open(name, "r") as f: | ||||
|     content = f.read() | ||||
| 
 | ||||
| for pip_package in p.data["default"]: | ||||
|     version = p.data["default"][pip_package] | ||||
|     if version == "*": | ||||
|         for package in global_packages: | ||||
|             package = package.lower() | ||||
|             if package.startswith(pip_package.lower()): | ||||
|                 substr = f'{pip_package} = "*"' | ||||
|                 content = content.replace(substr, package) | ||||
| 
 | ||||
| with open(name, "w") as f: | ||||
|     f.write(content) | ||||
							
								
								
									
										28
									
								
								app/ceph.py
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								app/ceph.py
									
										
									
									
									
								
							|  | @ -1,28 +0,0 @@ | |||
| import click | ||||
| import os | ||||
| import subprocess | ||||
| 
 | ||||
| 
 | ||||
| @click.group() | ||||
| def ceph(): | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| @ceph.command("setup") | ||||
| @click.option("--ceph_url", required=True) | ||||
| @click.option("--ssh_username", required=True) | ||||
| def setup(ceph_url, ssh_username): | ||||
|     try: | ||||
|         os.makedirs("/etc/ceph", exist_ok=True) | ||||
|         command = f"sftp -b ./ceph_batch_cmd {ssh_username}@{ceph_url}:/etc/ceph" | ||||
|         subprocess.check_output(command.split()) | ||||
|     except Exception: | ||||
|         p = subprocess.check_output(f"ssh-keyscan {ceph_url}".split()) | ||||
|         keys = p.decode("utf-8").strip().split("\n") | ||||
|         keys = "\n".join(keys) | ||||
|         with open(os.path.expanduser("~/.ssh/known_hosts"), "a") as known_hosts: | ||||
|             known_hosts.write(keys) | ||||
| 
 | ||||
|         os.makedirs("/etc/ceph", exist_ok=True) | ||||
|         command = f"sftp -b ./ceph_batch_cmd {ssh_username}@{ceph_url}:/etc/ceph" | ||||
|         subprocess.check_output(command.split()) | ||||
|  | @ -1,2 +0,0 @@ | |||
| lcd /etc/ceph | ||||
| get * | ||||
							
								
								
									
										3
									
								
								init.sh
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								init.sh
									
										
									
									
									
								
							|  | @ -18,7 +18,8 @@ apk add python3 ceph py2-pip py3-pip | |||
| # Some python package dependencies | ||||
| apk add libffi-dev openssl-dev make alpine-sdk gcc g++ python3-dev | ||||
| 
 | ||||
| apk add py3-grpcio  | ||||
| apk add py3-grpcio py3-protobuf | ||||
| 
 | ||||
| pip3 install --upgrade pip | ||||
| pip2 install --upgrade pip | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue