mirror of
				https://github.com/kenzok8/openwrt-packages.git
				synced 2025-10-30 07:50:37 +08:00 
			
		
		
		
	update 2022-04-11 16:22:56
This commit is contained in:
		
							
								
								
									
										45
									
								
								luci-app-clash/root/usr/share/clash/groups.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								luci-app-clash/root/usr/share/clash/groups.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| #!/bin/sh /etc/rc.common | ||||
| . /lib/functions.sh | ||||
| cfg_groups_set() | ||||
| { | ||||
|  | ||||
|    CFG_FILE="/etc/config/clash" | ||||
|    local section="$1" | ||||
|    config_get "name" "$section" "name" "" | ||||
|    config_get "old_name_cfg" "$section" "old_name_cfg" "" | ||||
|    config_get "old_name" "$section" "old_name" "" | ||||
|  | ||||
|    if [ -z "$name" ]; then | ||||
|       return | ||||
|    fi | ||||
|     | ||||
|      | ||||
|    if [ -z "$old_name_cfg" ]; then | ||||
|       uci set clash."$section".old_name_cfg="$name" | ||||
|       uci commit clash | ||||
|    fi | ||||
|     | ||||
|    if [ -z "$old_name" ]; then | ||||
|       uci set clash."$section".old_name="$name" | ||||
|       uci commit clash | ||||
|    fi | ||||
|     | ||||
| 	   | ||||
|    if [ "$name" != "$old_name_cfg" ] && [ ! -z "$old_name_cfg" ]; then | ||||
|    	  sed -i "s/old_name_cfg \'${old_name_cfg}\'/old_name_cfg \'${name}\'/g" $CFG_FILE 2>/dev/null | ||||
|       sed -i "s/groups \'${old_name_cfg}/groups \'${name}/g" $CFG_FILE 2>/dev/null | ||||
|       sed -i "s/other_group \'${old_name_cfg}/other_group \'${name}/g" $CFG_FILE 2>/dev/null | ||||
|       sed -i "s/new_servers_group \'${old_name_cfg}/new_servers_group \'${name}/g" $CFG_FILE 2>/dev/null | ||||
|       sed -i "s/relay_groups \'${old_name_cfg}/relay_groups \'${name}/g" $CFG_FILE 2>/dev/null	   | ||||
|       config_load "clash" | ||||
|    fi | ||||
|  | ||||
| } | ||||
|  | ||||
| start(){ | ||||
| status=$(ps|grep -c /usr/share/clash/groups.sh) | ||||
| [ "$status" -gt "3" ] && exit 0 | ||||
|  | ||||
|    config_load "clash" | ||||
|    config_foreach cfg_groups_set "groups" | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	![41898282+github-actions[bot]@users.noreply.github.com](/assets/img/avatar_default.png) github-actions[bot]
					github-actions[bot]