about summary refs log blame commit diff stats
path: root/npcoin
blob: 72588d041c82d0ba7ebdafc1f03a43f7a761e9dc (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                 
                                                                                                                                                            

                                                           
                               
      
                                                          

          

                                       

    
                                                 
      
                                                                            

          

                                                        

    
                                              
      
                                                                        

          

                                                     

    
                                                         
      
                                                                                    

          

                                                                 

    
                                                            
      
                                                                                       

          
                                                                   
                                                                   

    
#!/bin/bash

if [ "$#" -eq 0 ] || [ "${@^}" = "--help" ] || [ "${@^}" = "-h" ]
then
  /bin/echo "Usage:"
  /bin/echo "  npcoin <Nameofprogram> : to create pcoin directories for <Nameofprogram> (this should be run in the \"tcoin\" folder's containing directory)"
  /bin/echo "  npcoin [ --help | -h ] : to print this help"
else
  if [ -e "./tcoin/${@^}.txt" ]
  then
    /bin/echo "Sorry, './tcoin/${@^}.txt' already exists."
    exit 1
  else
    /bin/echo "0" > "./tcoin/${@^}.txt"
    /bin/chmod 600 "./tcoin/${@^}.txt"
  fi

  if [ -e "./tcoin/messages/${@^}_messages.txt" ]
  then
    /bin/echo "Sorry, './tcoin/messages/${@^}_messages.txt' already exists."
    exit 1
  else
    /usr/bin/touch "./tcoin/messages/${@^}_messages.txt"
    /bin/chmod 600 "./tcoin/messages/${@^}_messages.txt"
  fi

  if [ -e "./tcoin/program_accounting/${@^}" ]
  then
    /bin/echo "Sorry, './tcoin/program_accounting/${@^}' aleady exists."
    exit 1
  else
    /bin/mkdir "./tcoin/program_accounting/${@^}"
    /bin/chmod 700 "./tcoin/program_accounting/${@^}"
  fi

  if [ -e "./tcoin/program_accounting/${@^}/_TOTAL.txt" ]
  then
    /bin/echo "Sorry, './tcoin/program_accounting/${@^}/_TOTAL.txt' already exists."
    exit 1
  else
    /bin/echo "0" > "./tcoin/program_accounting/${@^}/_TOTAL.txt"
    /bin/chmod 600 "./tcoin/program_accounting/${@^}/_TOTAL.txt"
  fi

  if [ -e "./tcoin/program_accounting/${@^}/_MESSAGES.txt" ]
  then
    /bin/echo "Sorry, './tcoin/program_accounting/${@^}/_MESSAGES.txt' already exists."
    exit 1
  else
    /bin/echo "" > "./tcoin/program_accounting/${@^}/_MESSAGES.txt"
    /bin/chmod 600 "./tcoin/program_accounting/${@^}/_MESSAGES.txt"
  fi
fi